|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
php-general-digest-help
lists.php.net
Date: Sat Sep 01 2007 - 12:07:14 CDT
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
php-general Digest 1 Sep 2007 17:07:14 -0000 Issue 4994
Topics (messages 261582 through 261595):
Re: How to show proper time to users from around the world
261582 by: Hemanth
Re: Is a small memory footprint better for a php script?
261583 by: Per Jessen
Re: regular expression question
261584 by: Richard Heyes
strange reference behavior
261585 by: Robert Enyedi
261586 by: Martin Ellingham
261591 by: Robert Cummings
261592 by: Robert Cummings
261594 by: Robert Enyedi
mail() silly question
261587 by: Rodrigo Poblanno Balp
261588 by: Ludovic André
261589 by: chris smith
261593 by: Bastien Koert
Re: Which CAPTCHA is the besta?
261590 by: Ronald Wiplinger
Re: Best Practices for calling 'setup' classes that extend 'parent' classes?
261595 by: Graham Anderson
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscribe
lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscribe
lists.php.net
To post to the list, e-mail:
php-general
lists.php.net
----------------------------------------------------------------------
attached mail follows:
what is the time shown by gmail with every mail ?
attached mail follows:
Mark wrote:
> Hey,
>
> I'm wondering something about memory usage.
> I just looked at how much memory the newest phpbb is using and that's
> over 2 mega bytes!!
>
> Now i'm working on a php script that is currently using around 600
> kilo bytes.
>
> The question now is: what is better? a script with a small memory
> usage? or is that something i don't need to look at?
As a rule of thumb, using less resources (memory/disk/cpu) is better.
Though depending on your actual situation, it may not be _visibly_
better. (a large machine with a lot of resources can cope with a lot
of resource abuse/waste without performance ever suffering).
/Per Jessen, Zürich
attached mail follows:
> But how? The +[a-z]{2,} seems to allow at least two a-z clusters, but it
> doesn't include a period. /ml
Almost correct. The plus belongs to whatever comes before it, not after.
So what you're referring to as matching two or more characters but not
the period, is this:
[a-z]{2,}
And this will match one or more "subdomains":
([-a-z0-9]+\.)+
--
Richard Heyes
+44 (0)800 0213 172
http://www.websupportsolutions.co.uk
Knowledge Base and HelpDesk software
that can cut the cost of online support
attached mail follows:
Hi,
I've been studying the PHP reference mechanism (with PHP 5.2.1) and I'm
unsure if the following behavior is normal.
This code works as expected:
$a = 2;
$b = &$a;
//$c = &$a;
$c = $b;
$a = 1;
echo $c."\n"; // Prints "2" as expected
but this one does not:
$a = 2;
$b = &$a;
$c = &$a;
$c = $b; // Should overwrite the previous assignment, so $c
// should get a copy of $b (and NOT a reference)
$a = 1;
echo $c."\n"; // I would expect "2", but prints "1"
Could anyone please clarify why this happens?
Regards,
Robert
attached mail follows:
Robert Enyedi wrote:
> Hi,
>
> I've been studying the PHP reference mechanism (with PHP 5.2.1) and
> I'm unsure if the following behavior is normal.
>
> This code works as expected:
>
> $a = 2;
> $b = &$a;
> //$c = &$a;
> $c = $b;
> $a = 1;
>
> echo $c."\n"; // Prints "2" as expected
>
> but this one does not:
>
> $a = 2;
> $b = &$a;
> $c = &$a;
> $c = $b; // Should overwrite the previous assignment, so $c
> // should get a copy of $b (and NOT a reference)
> $a = 1;
>
> echo $c."\n"; // I would expect "2", but prints "1"
>
> Could anyone please clarify why this happens?
>
> Regards,
> Robert
>
This is because PHP5 has changed the default behaviour and $a = $b is
now call by reference as standard.
That's my understanding of it.
Martin
attached mail follows:
On Sat, 2007-09-01 at 13:06 +0300, Robert Enyedi wrote:
> Hi,
>
> I've been studying the PHP reference mechanism (with PHP 5.2.1) and I'm
> unsure if the following behavior is normal.
>
> This code works as expected:
>
> $a = 2;
> $b = &$a;
> //$c = &$a;
> $c = $b;
> $a = 1;
>
> echo $c."\n"; // Prints "2" as expected
>
> but this one does not:
>
> $a = 2;
> $b = &$a;
> $c = &$a;
> $c = $b; // Should overwrite the previous assignment, so $c
> // should get a copy of $b (and NOT a reference)
> $a = 1;
>
> echo $c."\n"; // I would expect "2", but prints "1"
>
> Could anyone please clarify why this happens?
Sure...
1: $a = 2;
2: $b = &$a;
3: $c = &$a;
4: $c = $b; // Should overwrite the previous assignment, so $c
5: // should get a copy of $b (and NOT a reference)
6: $a = 1;
7:
8: echo $c."\n"; // I would expect "2", but prints "1"
By line number...
1: Assign 2 to a variable called $a
2: Assign to $b a reference to $a
3: Assign to $c a reference to $a
4: Assign the value of $b to $c
(this does NOT break $c's reference to $a)
6: Assign the value 1 to $a
($a is currently referenced by $b and $c)
8: Echo $c which should be 1. You will get the same result
in PHP4
Cheers,
Rob.
--
...........................................................
SwarmBuy.com - http://www.swarmbuy.com
Leveraging the buying power of the masses!
...........................................................
attached mail follows:
On Sat, 2007-09-01 at 11:39 +0100, Martin Ellingham wrote:
> Robert Enyedi wrote:
> > Hi,
> >
> > I've been studying the PHP reference mechanism (with PHP 5.2.1) and
> > I'm unsure if the following behavior is normal.
> >
> > This code works as expected:
> >
> > $a = 2;
> > $b = &$a;
> > //$c = &$a;
> > $c = $b;
> > $a = 1;
> >
> > echo $c."\n"; // Prints "2" as expected
> >
> > but this one does not:
> >
> > $a = 2;
> > $b = &$a;
> > $c = &$a;
> > $c = $b; // Should overwrite the previous assignment, so $c
> > // should get a copy of $b (and NOT a reference)
> > $a = 1;
> >
> > echo $c."\n"; // I would expect "2", but prints "1"
> >
> > Could anyone please clarify why this happens?
> >
> > Regards,
> > Robert
> >
> This is because PHP5 has changed the default behaviour and $a = $b is
> now call by reference as standard.
In the above example no objects have been used. As such, nothing has
changed in the above semantics that do not exist in PHP4.
Cheers,
Rob.
--
...........................................................
SwarmBuy.com - http://www.swarmbuy.com
Leveraging the buying power of the masses!
...........................................................
attached mail follows:
Thanks for the clarifications.
Regards,
Robert
Robert Cummings wrote:
> On Sat, 2007-09-01 at 11:39 +0100, Martin Ellingham wrote:
>> Robert Enyedi wrote:
>>> Hi,
>>>
>>> I've been studying the PHP reference mechanism (with PHP 5.2.1) and
>>> I'm unsure if the following behavior is normal.
>>>
>>> This code works as expected:
>>>
>>> $a = 2;
>>> $b = &$a;
>>> //$c = &$a;
>>> $c = $b;
>>> $a = 1;
>>>
>>> echo $c."\n"; // Prints "2" as expected
>>>
>>> but this one does not:
>>>
>>> $a = 2;
>>> $b = &$a;
>>> $c = &$a;
>>> $c = $b; // Should overwrite the previous assignment, so $c
>>> // should get a copy of $b (and NOT a reference)
>>> $a = 1;
>>>
>>> echo $c."\n"; // I would expect "2", but prints "1"
>>>
>>> Could anyone please clarify why this happens?
>>>
>>> Regards,
>>> Robert
>>>
>> This is because PHP5 has changed the default behaviour and $a = $b is
>> now call by reference as standard.
>
> In the above example no objects have been used. As such, nothing has
> changed in the above semantics that do not exist in PHP4.
>
> Cheers,
> Rob.
attached mail follows:
I have a question that might be too silly for those of you who are PHP
gurus.
Here it comes:
I had a mail (specifically in the headers) function call like this:
$header = "";
$header .= 'From: info
villaarmonica.org.mx\r\n";
$header .= 'MIME-Version: 1.0\r\n";
$header .= 'Content-type: text/html; charset=iso-8859-1\r\n";
$header .= "Reply-To: ".utf8_decode($nombreVar)."
".utf8_decode($apellidosVar)."<$mailVar>\r\n";
$header .= "X-Mailer: PHP/".phpversion()."\r\n";
$header .= "X-Priority: 1";
and the mail(...) function always returned TRUE, but the mail was NOT sent.
After hours of... trial/error debugging, I noticed from an example that
it should be:
$header = "";
$header .= 'From: info
villaarmonica.org.mx' . "\r\n";
$header .= 'MIME-Version: 1.0' . "\r\n";
$header .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$header .= "Reply-To: ".utf8_decode($nombreVar)."
".utf8_decode($apellidosVar)."<$mailVar>\r\n";
$header .= "X-Mailer: PHP/".phpversion()."\r\n";
$header .= "X-Priority: 1";
Question:
Why? What's the real difference between
$header .= 'From: info
villaarmonica.org.mx' . "\r\n";
and
$header .= 'From: info
villaarmonica.org.mx\r\n";
?
If somebody knows, please let me know!
Thank you in advance.
attached mail follows:
Hi,
> Question:
>
> Why? What's the real difference between
> $header .= 'From: info
villaarmonica.org.mx' . "\r\n";
> and
> $header .= 'From: info
villaarmonica.org.mx\r\n";
>
Your second declaration is incorrect: you start with a single quote ('),
and you end with a double (").
So, you'd say "ok, let's fix it":
$header .= 'From: info
villaarmonica.org.mx\r\n';
BUT, special chars like \n or \r need to be inside a double-quoted
string in order to be taken into account.
This one is then correct:
$header .= 'From: info
villaarmonica.org.mx' . "\r\n";
This one as well:
$header .= "From: info
villaarmonica.org.mx\r\n";
Ludovic André
attached mail follows:
On 9/1/07, Rodrigo Poblanno Balp <balpo
gmx.net> wrote:
> I have a question that might be too silly for those of you who are PHP
> gurus.
>
> Here it comes:
>
> I had a mail (specifically in the headers) function call like this:
>
> $header = "";
> $header .= 'From: info
villaarmonica.org.mx\r\n";
> $header .= 'MIME-Version: 1.0\r\n";
> $header .= 'Content-type: text/html; charset=iso-8859-1\r\n";
> $header .= "Reply-To: ".utf8_decode($nombreVar)."
> ".utf8_decode($apellidosVar)."<$mailVar>\r\n";
> $header .= "X-Mailer: PHP/".phpversion()."\r\n";
> $header .= "X-Priority: 1";
>
> and the mail(...) function always returned TRUE, but the mail was NOT sent.
>
> After hours of... trial/error debugging, I noticed from an example that
> it should be:
>
> $header = "";
> $header .= 'From: info
villaarmonica.org.mx' . "\r\n";
> $header .= 'MIME-Version: 1.0' . "\r\n";
> $header .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
> $header .= "Reply-To: ".utf8_decode($nombreVar)."
> ".utf8_decode($apellidosVar)."<$mailVar>\r\n";
> $header .= "X-Mailer: PHP/".phpversion()."\r\n";
> $header .= "X-Priority: 1";
>
> Question:
>
> Why? What's the real difference between
> $header .= 'From: info
villaarmonica.org.mx' . "\r\n";
> and
> $header .= 'From: info
villaarmonica.org.mx\r\n";
Actually that's a parse error ;) You have a single quote at the start
and double at the end.
Anyway, the reason is interpolation. See
http://www.php.net/manual/en/language.types.string.php
Under "Single quoted":
.. escape sequences for special characters will not be expanded when
they occur in single quoted strings.
So you end up with a literal '\r\n' at the end of the line, not an
actual carriage return & newline that you expect.
--
Postgresql & php tutorials
http://www.designmagick.com/
attached mail follows:
no difference
bastien
----------------------------------------> Date: Sat, 1 Sep 2007 08:00:11 -0500> From: balpo
gmx.net> To: php-general
lists.php.net> Subject: [PHP] mail() silly question>> I have a question that might be too silly for those of you who are PHP> gurus.>> Here it comes:>> I had a mail (specifically in the headers) function call like this:>> $header = "";> $header .= 'From: info
villaarmonica.org.mx\r\n";> $header .= 'MIME-Version: 1.0\r\n";> $header .= 'Content-type: text/html; charset=iso-8859-1\r\n";> $header .= "Reply-To: ".utf8_decode($nombreVar)."> ".utf8_decode($apellidosVar)."\r\n";> $header .= "X-Mailer: PHP/".phpversion()."\r\n";> $header .= "X-Priority: 1";>> and the mail(...) function always returned TRUE, but the mail was NOT sent.>> After hours of... trial/error debugging, I noticed from an example that> it should be:>> $header = "";> $header .= 'From: info
villaarmonica.org.mx' . "\r\n";> $header .= 'MIME-Version: 1.0' . "\r\n";> $header .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";> $header .= "Reply-To: ".utf8_decode($nombreVar)."> ".utf8_decode($apellidosVar)."\r\n";> $header .= "X-Mailer: PHP/".phpversion()."\r\n";> $header .= "X-Priority: 1";>> Question:>> Why? What's the real difference between> $header .= 'From: info
villaarmonica.org.mx' . "\r\n";> and> $header .= 'From: info
villaarmonica.org.mx\r\n";>> ?> If somebody knows, please let me know!>> Thank you in advance.>> --> PHP General Mailing List (http://www.php.net/)> To unsubscribe, visit: http://www.php.net/unsub.php>
_________________________________________________________________
Discover the new Windows Vista
http://search.msn.com/results.aspx?q=windows+vista&mkt=en-US&form=QBRE
attached mail follows:
Hamza Saglam wrote:
> Not a script you can install/hack but why don't you have a look at:
> http://recaptcha.net/ ?
>
>
I am going to try that one. It sounds good and gives me a feeling to do
something good to the community as well.
Which version have you tried? Java or PHP? How to set-up PHP?
Some people say that captcha is just to bother humans, while the robots
are learning faster to deal with it!
bye
Ronald
> Regards,
> Hamza.
>
>
> ""Tony Di Croce"" <dicroce
gmail.com> wrote in message
> news:37c0928e0708161519y341b6d88q3b09c66d4f78be87
mail.gmail.com...
>
>> I need a CAPTCHA script.... Which one is the best? (I dont mind if its
>> somewhat difficult).
>>
>>
attached mail follows:
Many thanks :)
This was very helpful.
On Aug 26, 2007, at 8:27 PM, Richard Lynch wrote:
> Put all your classes into a single directory structure.
>
> Use http://php.net/set_include_path (or php.ini or .htaccess) to
> provide the FULL PATH to that directory.
>
> PHP now knows where to "start" its search, and essentially prepends
> that directory when it does an include.
>
> Assume this directory structure:
>
> /path/to/your/includes
> parent_class.php
> /child
> some_child_class.php
>
> This works:
> <?php
> set_include_path('/path/to/your/includes');
> include 'parent_class.php';
> include 'child/some_child_class.php';
> ?>
>
> Do not under any circumstances try to use './' or '../' in your
> include statements. You will only make yourself miserable in the long
> run.
>
> On Mon, August 20, 2007 1:52 pm, Graham Anderson wrote:
>> What is the best practice for correctly targeting 'include' paths
>> when using Initialization/Setup classes that extend Parent classes?
>>
>> In my extend_parent_class.php file, I have to provide an incorrect
>> relative path. Apparently, the path (that does work) is relative to
>> php file that calls the initialization/setup class
>> (call_the_extend_parent_class.php). Is there a less confusing way to
>> correctly target include paths when creating initialization classes?
>>
>> Should I be using absolute paths instead?
>>
>> many thanks in advance
>>
>>
>>
>> extend_parent_class.php:
>>
>> include_once('./path/to/parent_class.php'); # Works with 'incorrect'
>> relative path
>> //include_once('../path/to/parent_class.php'); # Fatal Error with
>> 'correct' relative path
>>
>> class Initialize_Parent_Class extends Parent_Class {
>>
>> function Initialize_Parent_Class()
>> {
>> $this->Parent_Class();
>> echo "This was successful and does not result in a fatal 'class not
>> found' error";
>> }
>>
>> }
>>
>>
>>
>> Call the initialization class.
>> call_the_extend_parent_class.php:
>> <?php
>>
>> require('./includes/extend_parent_class.php'); # initialize Parent
>> Class
>>
>> $parent_class = new Initialize_Parent_Class();
>> // prints 'This was successful and does not result in a fatal 'class
>> not found' error'
>>
>> ?>
>>
>> File structure:
>>
>> php
>> ++call_the_extend_parent_class.php
>> ++ includes directory
>> ++++ extend_parent_class.php
>> ++ classes directory
>> ++++ parent_class.php
>>
>> --
>> 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/browse/from/lynch
> Yeah, I get a buck. So?
>
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]