php-general Digest 2 Jan 2008 07:17:54 -0000 Issue 5212
Topics (messages 266451 through 266467):
Re: About search engine usability
266451 by: Børge Holen
foreach questions
266452 by: jekillen
266454 by: jekillen
266456 by: Martin Jerga
266460 by: Richard Lynch
266461 by: Richard Lynch
266463 by: jekillen
Re: foreach questions OT
266453 by: Børge Holen
Re: Try{} Catch()
266455 by: Martin Alterisio
variable substitution
266457 by: jekillen
266458 by: Casey
266459 by: Richard Lynch
266462 by: James Ausmus
266464 by: jekillen
266465 by: jekillen
Re: read email
266466 by: Manuel Lemos
best way for PHP page
266467 by: Alain Roger
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[EMAIL PROTECTED]
----------------------------------------------------------------------
--- Begin Message ---
On Tuesday 01 January 2008 19:21:09 Richard Lynch wrote:
> On Mon, December 31, 2007 5:19 pm, Jim Webber wrote:
> > Hello I'm building a website with a search engine.
> > Do you think it is more usable if the search interface had a search
> > button? or do you think it will be more convenient to not have button
> > to
> > let the users just push "enter" to search.
> >
> > I would appreciate any comment regarding this, thanks.
>
> Have the button, but make it tiny.
>
> There are always some users too new to know that they don't need a
> button.
>
> The rest can ignore the tiny bubbles. I mean button. :-v
I HATE pages with js forms (just because its js) and "uncomplete" forms. I
love surfing and finding information with just my trackball. The imense power
of linux gpm mark/copy - paste, makes us undeniable lazy.
I actually got to go looking for the extra :'
'
to fetch'n copy the "virtual" enter... takes a few extra ms at than, but I
don't have to move a finger.
If I got the button I don't have to think about it, without it I got no
choice.
>
> --
> Some people have a "gift" link here.
> Know what I want?
> I want you to buy a CD from some indie artist.
> http://cdbaby.com/from/lynch
> Yeah, I get a buck. So?
--
---
Børge Holen
http://www.arivene.net
--- End Message ---
--- Begin Message ---
Hello;
I have this section of code:
@include('tmp_index.php');
foreach($index as $key -> $value)
{
if($input == $key)
{
$target_file = $value;
}
}
And I am getting this error:
Fatal error: Cannot access empty property in <path>/confirmation.php on
line 131
Several questions:
How long can an index be in an associative array? (the indexes I use in
this array are 32 character hashes)
Can it start with a number (since a hash can start with a number)
Can I use $index as an array name? (I do not remember off hand what the
reserved key words are)
I am not sure what the "empty property" is that it is referring to.
Thank you in advance for info;
Jeff K
--- End Message ---
--- Begin Message ---
On Jan 1, 2008, at 11:59 AM, Martin Jerga wrote:
Hello,
the problem is in this part of code $key -> $value
This notation means that you are trying to access property $value on
the object $key.
Just replace it with $key => $value and you will get the result as
expected.
Martin J
Thank you for the response;
I should have known. I don't use this type of loop often enough
to get it straight the first time.
Jeff K
jekillen wrote / napísal(a):
Hello;
I have this section of code:
@include('tmp_index.php');
foreach($index as $key -> $value)
{
if($input == $key)
{
$target_file = $value;
}
}
And I am getting this error:
Fatal error: Cannot access empty property in <path>/confirmation.php
on line 131
Several questions:
How long can an index be in an associative array? (the indexes I use
in this array are 32 character hashes)
Can it start with a number (since a hash can start with a number)
Can I use $index as an array name? (I do not remember off hand what
the reserved key words are)
I am not sure what the "empty property" is that it is referring to.
Thank you in advance for info;
Jeff K
--- End Message ---
--- Begin Message ---
Hello,
the problem is in this part of code $key -> $value
This notation means that you are trying to access property $value on the
object $key.
Just replace it with $key => $value and you will get the result as expected.
Martin J
jekillen wrote / napísal(a):
Hello;
I have this section of code:
@include('tmp_index.php');
foreach($index as $key -> $value)
{
if($input == $key)
{
$target_file = $value;
}
}
And I am getting this error:
Fatal error: Cannot access empty property in <path>/confirmation.php on
line 131
Several questions:
How long can an index be in an associative array? (the indexes I use in
this array are 32 character hashes)
Can it start with a number (since a hash can start with a number)
Can I use $index as an array name? (I do not remember off hand what the
reserved key words are)
I am not sure what the "empty property" is that it is referring to.
Thank you in advance for info;
Jeff K
--- End Message ---
--- Begin Message ---
-> is the Object operator.
You want => which is used in foreach
On Tue, January 1, 2008 1:47 pm, jekillen wrote:
> Hello;
> I have this section of code:
>
> @include('tmp_index.php');
> foreach($index as $key -> $value)
> {
> if($input == $key)
> {
> $target_file = $value;
> }
> }
> And I am getting this error:
> Fatal error: Cannot access empty property in <path>/confirmation.php
> on
> line 131
>
> Several questions:
> How long can an index be in an associative array? (the indexes I use
> in
> this array are 32 character hashes)
> Can it start with a number (since a hash can start with a number)
> Can I use $index as an array name? (I do not remember off hand what
> the
> reserved key words are)
> I am not sure what the "empty property" is that it is referring to.
> Thank you in advance for info;
> Jeff K
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?
--- End Message ---
--- Begin Message ---
Hit send too soon. Sorry!
On Tue, January 1, 2008 2:05 pm, jekillen wrote:
>>> Several questions:
>>> How long can an index be in an associative array? (the indexes I
>>> use
>>> in this array are 32 character hashes)
As far as I know, it can be as big as your RAM will hold...
>>> Can it start with a number (since a hash can start with a number)
Yes.
A variable name cannot start with a number.
>>> Can I use $index as an array name? (I do not remember off hand what
>>> the reserved key words are)
You can use '$index' if you want, sure.
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?
--- End Message ---
--- Begin Message ---
On Jan 1, 2008, at 3:34 PM, Richard Lynch wrote:
Hit send too soon. Sorry!
On Tue, January 1, 2008 2:05 pm, jekillen wrote:
Several questions:
How long can an index be in an associative array? (the indexes I
use
in this array are 32 character hashes)
As far as I know, it can be as big as your RAM will hold...
Can it start with a number (since a hash can start with a number)
Yes.
A variable name cannot start with a number.
Can I use $index as an array name? (I do not remember off hand what
the reserved key words are)
You can use '$index' if you want, sure.
Thanks for the info;
Jeff K
--- End Message ---
--- Begin Message ---
On Tuesday 01 January 2008 20:47:18 jekillen wrote:
> Hello;
> I have this section of code:
>
> @include('tmp_index.php');
> foreach($index as $key -> $value)
> {
> if($input == $key)
> {
> $target_file = $value;
> }
> }
> And I am getting this error:
> Fatal error: Cannot access empty property in <path>/confirmation.php on
> line 131
I bought the property on line 131 just before you tried to access it. I put up
a high electric fence, just over the path and theres nothing there yet, but
working up a mortgage right now. ;D sry. late nite last night.
>
> Several questions:
> How long can an index be in an associative array? (the indexes I use in
> this array are 32 character hashes)
> Can it start with a number (since a hash can start with a number)
> Can I use $index as an array name? (I do not remember off hand what the
> reserved key words are)
> I am not sure what the "empty property" is that it is referring to.
> Thank you in advance for info;
> Jeff K
--
---
Børge Holen
http://www.arivene.net
--- End Message ---
--- Begin Message ---
2007/12/31, Richard Lynch <[EMAIL PROTECTED]>:
>
> On Sun, December 23, 2007 3:50 pm, Martin Alterisio wrote:
> > It's not supposed to be practical, it's just a way to handle errors.
> > You
> > shouldn't rely on try/catch for algorithm implementation.
> >
> > You create exceptions for errors and unexpected behavior. Then in some
> > other
> > part of the system you use try/catch to prevent the code from
> > terminating
> > abruptly. You catch the exception (you should know which exceptions
> > can be
> > thrown), and act accordingly. Either closing resources, add a log
> > message
> > with debug information, and/or sending an error message to the user.
>
> Except that once you start trying to integrate several large bodies of
> code, you have NO IDEA what exceptions can be thrown, and even less
> idea where they didn't get caught and handled properly.
>
> Worse, many times the library[ies] you are integrating to an abysmal
> job of doing anyting intelligent with the catch block, and you're
> stuck with something even worse than set_error_handler.
>
> try/catch works great for small/medium projects, or even large
> well-documented projects perhaps, but as soon as you start trying to
> integrate several projects...
>
> Well, in MY experience, try/catch just ended up biting me in the butt...
>
> ymmv
> naiaa
> ianal
>
>
You made me realize that I hadn't thought much on the subject. Now I
understand the benefits of how Java integrates exceptions more tightly into
system design. Maybe it would be a good idea to assimilate those features.
The features I'm referring to is the declaration of exceptions thrown by a
function. If you use a function that declares throwing exceptions and don't
use a corresponding try/catch around it, the compile will fail because
you're not handling the exceptions. You can either use a try/catch or
forward the exception by declaring that you will also throw exceptions.
Adding these features to PHP is, I think, not possible (compile-time php
doesn't know what will be the extent of the system at runtime). But you can
use a code analyzer that would parse metadata, such as the one used for
doc-comments, and flag this problems before putting the code into
production.
--- End Message ---
--- Begin Message ---
Hello again;
I have two variables declared in the global scope of a script.
$string_a = 'stuff $string_b and more stuff';
$string_b = '';
One is a string with a reference for substitution to the other
string which is empty.
In the processing body of the script are if/if else blocks.
In these blocks I want to use $string_a and
set $string_b to a value
if( condition)
{ $string_b = 'by the way;';... etc
so $string_a should read:
"stuff and by the way; and more stuff"
But this substitution will not take place
in the context of the else if block. I do not
want to write $string_a in at least 5 different
if else blocks because it is about 10 lines
intended to be an e-mail message body -> !SPAM.
this script is used to process data sent from a
link in another e-mail message used to validate
and e-mail address.
Q: Is there a way to get the substitution to take
place here? (by reference, maybe?)
Thank you in advance for info
Jeff K
--- End Message ---
--- Begin Message ---
On Jan 1, 2008 2:17 PM, jekillen <[EMAIL PROTECTED]> wrote:
> Hello again;
> I have two variables declared in the global scope of a script.
> $string_a = 'stuff $string_b and more stuff';
> $string_b = '';
> One is a string with a reference for substitution to the other
> string which is empty.
> In the processing body of the script are if/if else blocks.
> In these blocks I want to use $string_a and
> set $string_b to a value
> if( condition)
> { $string_b = 'by the way;';... etc
> so $string_a should read:
> "stuff and by the way; and more stuff"
> But this substitution will not take place
> in the context of the else if block. I do not
> want to write $string_a in at least 5 different
> if else blocks because it is about 10 lines
> intended to be an e-mail message body -> !SPAM.
>
> this script is used to process data sent from a
> link in another e-mail message used to validate
> and e-mail address.
>
> Q: Is there a way to get the substitution to take
> place here? (by reference, maybe?)
>
> Thank you in advance for info
> Jeff K
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Hmmm... will this work?
function get_string_a() {
global $string_b;
return "stuff $string_b and more stuff";
}
-Casey
--- End Message ---
--- Begin Message ---
On Tue, January 1, 2008 4:17 pm, jekillen wrote:
> Hello again;
> I have two variables declared in the global scope of a script.
> $string_a = 'stuff $string_b and more stuff';
> $string_b = '';
> One is a string with a reference for substitution to the other
> string which is empty.
> In the processing body of the script are if/if else blocks.
> In these blocks I want to use $string_a and
> set $string_b to a value
> if( condition)
> { $string_b = 'by the way;';... etc
> so $string_a should read:
> "stuff and by the way; and more stuff"
> But this substitution will not take place
> in the context of the else if block. I do not
> want to write $string_a in at least 5 different
> if else blocks because it is about 10 lines
> intended to be an e-mail message body -> !SPAM.
>
> this script is used to process data sent from a
> link in another e-mail message used to validate
> and e-mail address.
>
> Q: Is there a way to get the substitution to take
> place here? (by reference, maybe?)
http://php.net/str_replace
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?
--- End Message ---
--- Begin Message ---
On Jan 1, 2008 2:17 PM, jekillen <[EMAIL PROTECTED]> wrote:
> Hello again;
> I have two variables declared in the global scope of a script.
> $string_a = 'stuff $string_b and more stuff';
> $string_b = '';
> One is a string with a reference for substitution to the other
> string which is empty.
> In the processing body of the script are if/if else blocks.
> In these blocks I want to use $string_a and
> set $string_b to a value
> if( condition)
> { $string_b = 'by the way;';... etc
> so $string_a should read:
> "stuff and by the way; and more stuff"
> But this substitution will not take place
> in the context of the else if block. I do not
> want to write $string_a in at least 5 different
> if else blocks because it is about 10 lines
> intended to be an e-mail message body -> !SPAM.
Several ways to do this (and avoid globals or a str_replace call):
#1:
if (condition)
{
$string_b = 'blah';
} else if (condition2)
{
$string_b = 'foo';
} else if (condition3)
{
$string_b = 'bar';
} else
{
$string_b = 'other';
}
$string_a = "stuff $string_b and more stuff";
The reason for this is the variable substition occurs *at the time of
assignment* - not later.
Another way, if it's not easy to have your string_b setting
conditionals all in a row like that (or if this needs to be done
elsewhere in code, as well), would be:
function assignStrA($subStr)
{
$retVal = "stuff $subStr and more stuff";
return $retVal;
}
if (cond1)
{
$string_a = assignStrA('foo');
} else if (cond2)
{
$string_a = assignStrA('bar');
} else
{
$string_a = assignStrA('other');
}
HTH-
James Ausmus
Integration Software Engineer
HTRI
"Cross Technology Integration Specialists"
503-538-8085
>
> this script is used to process data sent from a
> link in another e-mail message used to validate
> and e-mail address.
>
> Q: Is there a way to get the substitution to take
> place here? (by reference, maybe?)
>
> Thank you in advance for info
> Jeff K
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
On Jan 1, 2008, at 3:31 PM, Richard Lynch wrote:
On Tue, January 1, 2008 4:17 pm, jekillen wrote:
Hello again;
I have two variables declared in the global scope of a script.
$string_a = 'stuff $string_b and more stuff';
$string_b = '';
One is a string with a reference for substitution to the other
string which is empty.
In the processing body of the script are if/if else blocks.
In these blocks I want to use $string_a and
set $string_b to a value
if( condition)
{ $string_b = 'by the way;';... etc
so $string_a should read:
"stuff and by the way; and more stuff"
But this substitution will not take place
in the context of the else if block. I do not
want to write $string_a in at least 5 different
if else blocks because it is about 10 lines
intended to be an e-mail message body -> !SPAM.
this script is used to process data sent from a
link in another e-mail message used to validate
and e-mail address.
Q: Is there a way to get the substitution to take
place here? (by reference, maybe?)
http://php.net/str_replace
O.K. that looks good, I can put in a target string to replace
instead of the variable.
Thanks for the suggestion;
jeff K
--- End Message ---
--- Begin Message ---
On Jan 1, 2008, at 3:48 PM, James Ausmus wrote:
On Jan 1, 2008 2:17 PM, jekillen <[EMAIL PROTECTED]> wrote:
Hello again;
I have two variables declared in the global scope of a script.
$string_a = 'stuff $string_b and more stuff';
$string_b = '';
One is a string with a reference for substitution to the other
string which is empty.
In the processing body of the script are if/if else blocks.
In these blocks I want to use $string_a and
set $string_b to a value
if( condition)
{ $string_b = 'by the way;';... etc
so $string_a should read:
"stuff and by the way; and more stuff"
But this substitution will not take place
in the context of the else if block. I do not
want to write $string_a in at least 5 different
if else blocks because it is about 10 lines
intended to be an e-mail message body -> !SPAM.
Several ways to do this (and avoid globals or a str_replace call):
#1:
if (condition)
{
$string_b = 'blah';
} else if (condition2)
{
$string_b = 'foo';
} else if (condition3)
{
$string_b = 'bar';
} else
{
$string_b = 'other';
}
$string_a = "stuff $string_b and more stuff";
The reason for this is the variable substition occurs *at the time of
assignment* - not later.
Another way, if it's not easy to have your string_b setting
conditionals all in a row like that (or if this needs to be done
elsewhere in code, as well), would be:
function assignStrA($subStr)
{
$retVal = "stuff $subStr and more stuff";
return $retVal;
}
if (cond1)
{
$string_a = assignStrA('foo');
} else if (cond2)
{
$string_a = assignStrA('bar');
} else
{
$string_a = assignStrA('other');
}
This looks good
Thanks for the suggestion;
Jeff K
this script is used to process data sent from a
link in another e-mail message used to validate
and e-mail address.
Q: Is there a way to get the substitution to take
place here? (by reference, maybe?)
Thank you in advance for info
Jeff K
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Hello,
on 12/30/2007 06:19 PM Yui Hiroaki said the following:
> HI!
>
> I am trying to access qmail with php.
>
> Why!
> Because I would like to read mail who someone send an email me to qmail.
>
> If anyone knows the code, please send me the code.
The easiest way to to associate a POP3 mailbox to the address you are
receiving e-mail and the use a POP3 client class like this to retrieve
the e-mail messages you want.
http://www.phpclasses.org/pop3class
--
Regards,
Manuel Lemos
Metastorage - Data object relational mapping layer generator
http://www.metastorage.net/
PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
--- End Message ---
--- Begin Message ---
Hi,
i would like to improve my coding quality when i use PHP code and for that i
would request your help.
in my web developer experience, i have to confess that i've never succeeded
in spliting PHP code from HTML code.
i mean that all my web pages consist of PHP code mixed with HTML code (for
rendering pages).
Some developers tell it's possible to write only PHP code for web page. i
agree with them but only when those PHP pages do not render web elements
(write text, display pictures, display formular, ...).
the purpose of my post is to know if i can really (at 100%) split client
code (display images, write text,...) from server code (move or copy data to
DB, create connection objects,...)
so what do you think about that ?
--
Alain
------------------------------------
Windows XP SP2
PostgreSQL 8.2.4 / MS SQL server 2005
Apache 2.2.4
PHP 5.2.4
C# 2005-2008
--- End Message ---