php-general Digest 10 Jun 2010 18:06:30 -0000 Issue 6791

2010-06-10 Thread php-general-digest-help

php-general Digest 10 Jun 2010 18:06:30 - Issue 6791

Topics (messages 306004 through 306010):

Re: Question - foreach.
306004 by: tedd
306005 by: Paul M Foster
306006 by: Shreyas
306009 by: tedd

Re: PHP app  Server Load
306007 by: Nathan Rixham

Re: Generic Email
306008 by: Michiel Sikma

Redirect to
306010 by: Ahmed Mohsen

Administrivia:

To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
php-gene...@lists.php.net


--
---BeginMessage---

At 7:19 AM +0530 6/10/10, Shreyas wrote:

PHP'ers,

I am reading a PHP book which explains foreach and at the end says : *'When
foreach starts walking through an array, it moves the pointer to
the beginning of the array. You don't need to reset an array before
walking through it with foreach.'*
*
*
*Does this mean - *
*1) Before I navigate the array, foreach will bring the pointer to the
starting key?*
*2) After the first index, it goes to 2nd, 3rd, and nth? *


Regards,
Shreyas


Shreyas:

This is one of those questions that you can test very easily, just 
initialize an array and try it.


?php

$test = array(a, b, c, d);
foreach ($test as $value)
   {
   echo(value = $value br);
   }

?

As the references show, there are two versions of the foreach, the 
one above and this:


?php

$test = array(a, b, c, d);
foreach ($test as $key = $value)
   {
   echo($key= $key  value=$value br);
   }

?

Note that you can pull-out the index (i.e., $key) as well as the 
value (i.e., $value) of each index. The br is only to add a 
linefeed in html.


This is a bit easier than using a for() loop.

Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com
---End Message---
---BeginMessage---
On Thu, Jun 10, 2010 at 07:03:28AM -0400, tedd wrote:

 At 7:19 AM +0530 6/10/10, Shreyas wrote:
 PHP'ers,

 I am reading a PHP book which explains foreach and at the end says : *'When
 foreach starts walking through an array, it moves the pointer to
 the beginning of the array. You don't need to reset an array before
 walking through it with foreach.'*
 *
 *
 *Does this mean - *
 *1) Before I navigate the array, foreach will bring the pointer to the
 starting key?*
 *2) After the first index, it goes to 2nd, 3rd, and nth? *


 Regards,
 Shreyas

 Shreyas:

 This is one of those questions that you can test very easily, just
 initialize an array and try it.

+1

This is Tedd's modus operandi. His website(s) are full of exactly this
type of thing. And I have to agree. I can't count the number of
questions I *haven't* asked on this list, because I built a page to test
a particular concept. And this sort of activity (as opposed to just
reading about something) really locks in your understanding of a
concept.

Paul

-- 
Paul M. Foster
---End Message---
---BeginMessage---
All,

I tried and tested it but wanted a solid confirmation on it. I felt foreach
usage is better than manual way of next(), prev() et al.

Thanks for the comments. I consider the thread answered and solved unless
someone has anything more to add.

Regards,
Shreyas

On Thu, Jun 10, 2010 at 7:02 PM, Paul M Foster pa...@quillandmouse.comwrote:

 On Thu, Jun 10, 2010 at 07:03:28AM -0400, tedd wrote:

  At 7:19 AM +0530 6/10/10, Shreyas wrote:
  PHP'ers,
 
  I am reading a PHP book which explains foreach and at the end says :
 *'When
  foreach starts walking through an array, it moves the pointer to
  the beginning of the array. You don't need to reset an array before
  walking through it with foreach.'*
  *
  *
  *Does this mean - *
  *1) Before I navigate the array, foreach will bring the pointer to the
  starting key?*
  *2) After the first index, it goes to 2nd, 3rd, and nth? *
 
 
  Regards,
  Shreyas
 
  Shreyas:
 
  This is one of those questions that you can test very easily, just
  initialize an array and try it.

 +1

 This is Tedd's modus operandi. His website(s) are full of exactly this
 type of thing. And I have to agree. I can't count the number of
 questions I *haven't* asked on this list, because I built a page to test
 a particular concept. And this sort of activity (as opposed to just
 reading about something) really locks in your understanding of a
 concept.

 Paul

 --
 Paul M. Foster

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
Regards,
Shreyas
---End Message---
---BeginMessage---

At 9:32 AM -0400 6/10/10, Paul M Foster wrote:

On Thu, Jun 10, 2010 at 07:03:28AM -0400, tedd wrote:

  This is one of those questions that you can test very easily, just

 initialize an array and try it.


+1

This is Tedd's modus operandi. His website(s) are full of exactly this
type of thing. And I have to agree. I can't count the number 

Re: [PHP] Question - foreach.

2010-06-10 Thread tedd

At 7:19 AM +0530 6/10/10, Shreyas wrote:

PHP'ers,

I am reading a PHP book which explains foreach and at the end says : *'When
foreach starts walking through an array, it moves the pointer to
the beginning of the array. You don't need to reset an array before
walking through it with foreach.'*
*
*
*Does this mean - *
*1) Before I navigate the array, foreach will bring the pointer to the
starting key?*
*2) After the first index, it goes to 2nd, 3rd, and nth? *


Regards,
Shreyas


Shreyas:

This is one of those questions that you can test very easily, just 
initialize an array and try it.


?php

$test = array(a, b, c, d);
foreach ($test as $value)
   {
   echo(value = $value br);
   }

?

As the references show, there are two versions of the foreach, the 
one above and this:


?php

$test = array(a, b, c, d);
foreach ($test as $key = $value)
   {
   echo($key= $key  value=$value br);
   }

?

Note that you can pull-out the index (i.e., $key) as well as the 
value (i.e., $value) of each index. The br is only to add a 
linefeed in html.


This is a bit easier than using a for() loop.

Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Question - foreach.

2010-06-10 Thread Paul M Foster
On Thu, Jun 10, 2010 at 07:03:28AM -0400, tedd wrote:

 At 7:19 AM +0530 6/10/10, Shreyas wrote:
 PHP'ers,

 I am reading a PHP book which explains foreach and at the end says : *'When
 foreach starts walking through an array, it moves the pointer to
 the beginning of the array. You don't need to reset an array before
 walking through it with foreach.'*
 *
 *
 *Does this mean - *
 *1) Before I navigate the array, foreach will bring the pointer to the
 starting key?*
 *2) After the first index, it goes to 2nd, 3rd, and nth? *


 Regards,
 Shreyas

 Shreyas:

 This is one of those questions that you can test very easily, just
 initialize an array and try it.

+1

This is Tedd's modus operandi. His website(s) are full of exactly this
type of thing. And I have to agree. I can't count the number of
questions I *haven't* asked on this list, because I built a page to test
a particular concept. And this sort of activity (as opposed to just
reading about something) really locks in your understanding of a
concept.

Paul

-- 
Paul M. Foster

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Question - foreach.

2010-06-10 Thread Shreyas
All,

I tried and tested it but wanted a solid confirmation on it. I felt foreach
usage is better than manual way of next(), prev() et al.

Thanks for the comments. I consider the thread answered and solved unless
someone has anything more to add.

Regards,
Shreyas

On Thu, Jun 10, 2010 at 7:02 PM, Paul M Foster pa...@quillandmouse.comwrote:

 On Thu, Jun 10, 2010 at 07:03:28AM -0400, tedd wrote:

  At 7:19 AM +0530 6/10/10, Shreyas wrote:
  PHP'ers,
 
  I am reading a PHP book which explains foreach and at the end says :
 *'When
  foreach starts walking through an array, it moves the pointer to
  the beginning of the array. You don't need to reset an array before
  walking through it with foreach.'*
  *
  *
  *Does this mean - *
  *1) Before I navigate the array, foreach will bring the pointer to the
  starting key?*
  *2) After the first index, it goes to 2nd, 3rd, and nth? *
 
 
  Regards,
  Shreyas
 
  Shreyas:
 
  This is one of those questions that you can test very easily, just
  initialize an array and try it.

 +1

 This is Tedd's modus operandi. His website(s) are full of exactly this
 type of thing. And I have to agree. I can't count the number of
 questions I *haven't* asked on this list, because I built a page to test
 a particular concept. And this sort of activity (as opposed to just
 reading about something) really locks in your understanding of a
 concept.

 Paul

 --
 Paul M. Foster

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
Regards,
Shreyas


[PHP] Re: PHP app Server Load

2010-06-10 Thread Nathan Rixham

Dan Joseph wrote:

Hi,

This is slightly OT...

We're wrapping up a new PHP/MySQL driven web site built on the Zend
Framework.  We're anticipating a couple hundred thousand members with
several thousand of them coming to the site at once.  I'm trying to figure
out how to determine how many servers we need to support the load.

I've done initial testing on a Xeon 3220 server, but we're looking at an i7
cpu based server now.

Anyone know a good way to estimate load based on actually numbers compared
to benchmark results from intel on a faster server?


Hammer a single instance of the server with ab, get some figures on how 
many requests per second you can handle then divide by how much traffic 
you expect :)


Before investing in the servers, it may an idea to cache as much as you 
can and let apache serve static files where ever possible, even if the 
cache'd files are updated once every 10 seconds it's still a huge weight 
off the server in high traffic sites. Simple web server config tweaks 
can make a huge difference too, such as dropping the keep alive right 
down so requests are served and workers freed quicker, likewise with 
mysql query cache settings and zend optimizer for PHP (+similar).


Personally I tend to split setups for high traffic sites in to 3 tiers, 
static files on one server, dynamic + app code on another, and db on the 
final 3rd server - then scale up each tier adding servers as needed.


In all honesty, there is no way for anybody to tell you how many servers 
of what spec you'll need, because the biggest factor here your PHP code 
and MySQL queries, if you were purely serving static files though then 
circa 2000 requests per second is a good guestimate.


Best,

Nathan

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Generic Email

2010-06-10 Thread Michiel Sikma
On 9 June 2010 11:59, Richard Quadling rquadl...@gmail.com wrote:

 On 9 June 2010 09:08, Amit Bobade a...@e-arth.in wrote:
  Hi friends,
  I am new in  PHP. I want to know that how to send an email in HTML
  format(i.e. with proper header, footer, etc) in PHP.
   Please suggest me with code.
 
  --
  Thanks and Regards,
  Amit



Well, you can simply use PHP's built in mail() function, documented here:
http://php.net/manual/en/function.mail.php
It's extremely easy to use, particularly if you copy and change the code
examples.

If you want something more powerful, try Swift Mailer:
http://swiftmailer.org/

Michiel


Re: [PHP] Question - foreach.

2010-06-10 Thread tedd

At 9:32 AM -0400 6/10/10, Paul M Foster wrote:

On Thu, Jun 10, 2010 at 07:03:28AM -0400, tedd wrote:

  This is one of those questions that you can test very easily, just

 initialize an array and try it.


+1

This is Tedd's modus operandi. His website(s) are full of exactly this
type of thing. And I have to agree. I can't count the number of
questions I *haven't* asked on this list, because I built a page to test
a particular concept. And this sort of activity (as opposed to just
reading about something) really locks in your understanding of a
concept.

Paul


Paul:

Now, if I could get the old memory to lock in and remember it, it 
would be great!


I spend much of my time thinking Did I do that before?

Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Redirect to

2010-06-10 Thread Ahmed Mohsen

Hi folks,
I know that this is not a php question, but I'm sure it some kind 
related to it.  I need to put my public files under public folder, and 
other includes files and database config in other folder not shown to 
the public, but i don't know how to do that. I hope if some one show me 
how to achieve this.


For example, this is the directory structure:

/root
--/includes
db.php
config.php

--/public
/index.php
/images
/admin
--/login.php



I don't want to enter (example.com/public) to view index.php file.  I 
just want to enter (example.com) and it redirects to the public folder 
and shows only (example.com/index.php) in the URL.  And for login.php 
should display (example.com/admin/login.php) not 
(example.com/public/admin/login.php)


Kind regards,
Ahmed.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Redirect to

2010-06-10 Thread Daniel P. Brown
On Thu, Jun 10, 2010 at 14:06, Ahmed Mohsen mre...@gmail.com wrote:
[snip!]

 I don't want to enter (example.com/public) to view index.php file.  I just
 want to enter (example.com) and it redirects to the public folder and shows
 only (example.com/index.php) in the URL.  And for login.php should display
 (example.com/admin/login.php) not (example.com/public/admin/login.php)

That's an HTTP server configuration.  For example, with Apache,
you should look at the DocumentRoot setting.

-- 
/Daniel P. Brown
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
We now offer SAME-DAY SETUP on a new line of servers!

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Redirect to

2010-06-10 Thread Ashley Sheridan
On Thu, 2010-06-10 at 21:06 +0300, Ahmed Mohsen wrote:

 Hi folks,
 I know that this is not a php question, but I'm sure it some kind 
 related to it.  I need to put my public files under public folder, and 
 other includes files and database config in other folder not shown to 
 the public, but i don't know how to do that. I hope if some one show me 
 how to achieve this.
 
 For example, this is the directory structure:
 
 /root
 --/includes
 db.php
 config.php
 
 --/public
 /index.php
 /images
 /admin
 --/login.php
 
 
 
 I don't want to enter (example.com/public) to view index.php file.  I 
 just want to enter (example.com) and it redirects to the public folder 
 and shows only (example.com/index.php) in the URL.  And for login.php 
 should display (example.com/admin/login.php) not 
 (example.com/public/admin/login.php)
 
 Kind regards,
 Ahmed.
 


If /public is your web root, then alter your virtual hosts file to
reflect this, so that it is the one that is used as the web root.

If /public is not your web root, then you could consider using
mod_rewrite() to internally redirect the content the visitors see,
without them actually knowing about it.

Thanks,
Ash
http://www.ashleysheridan.co.uk




[PHP] bug in mkdir?

2010-06-10 Thread Mike Wright

Hi all,

Using 5.2.9

I'm trying to create a directory but it is being created with incorrect 
permissions.  I'm following the online manual.


This is the command being used:

mkdir('/srv/www/domain/data/R1276190214358/thumbs', 0770, true);

This is what is created:

drwxr-x--- 2 apache apache 4096 2010-06-10 10:33 R1276190214358

Isn't that supposed to be 0770 instead of 0750?  Either the manual is 
wrong, the command is broken, or I'm screwing it up (most likely).


Thanks for any help,
Mike Wright

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] bug in mkdir?

2010-06-10 Thread Ashley Sheridan
On Thu, 2010-06-10 at 11:32 -0700, Mike Wright wrote:

 Hi all,
 
 Using 5.2.9
 
 I'm trying to create a directory but it is being created with incorrect 
 permissions.  I'm following the online manual.
 
 This is the command being used:
 
  mkdir('/srv/www/domain/data/R1276190214358/thumbs', 0770, true);
 
 This is what is created:
 
  drwxr-x--- 2 apache apache 4096 2010-06-10 10:33 R1276190214358
 
 Isn't that supposed to be 0770 instead of 0750?  Either the manual is 
 wrong, the command is broken, or I'm screwing it up (most likely).
 
 Thanks for any help,
 Mike Wright
 

Did the R1276190214358 directory already exist? If so, it will retain
the permissions it had, and only the thumbs sub-directory within it will
have the new permissions.

Also, is this on a shared hosting server? It could be that a security
restriction in-place is not allowing the permissions to be configured as
the directory is written, and you may have to manually update them with
the chmod() function.

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] bug in mkdir? [SOLVED]

2010-06-10 Thread Mike Wright

Ashley Sheridan wrote:

On Thu, 2010-06-10 at 11:32 -0700, Mike Wright wrote:


Hi all,

Using 5.2.9

I'm trying to create a directory but it is being created with incorrect 
permissions.  I'm following the online manual.


This is the command being used:

 mkdir('/srv/www/domain/data/R1276190214358/thumbs', 0770, true);

This is what is created:

 drwxr-x--- 2 apache apache 4096 2010-06-10 10:33 R1276190214358

Isn't that supposed to be 0770 instead of 0750?  Either the manual is 
wrong, the command is broken, or I'm screwing it up (most likely).


Thanks for any help,
Mike Wright





Hi, Ash.  Thanks for the help.


Did the R1276190214358 directory already exist?


No.

 If so, it will retain

the permissions it had, and only the thumbs sub-directory within it will
have the new permissions.

Also, is this on a shared hosting server? It could be that a security
restriction in-place is not allowing the permissions to be configured as
the directory is written, and you may have to manually update them with
the chmod() function.


It's under my control.

Solution: run umask(000) first.  (of the 3 choices above it turned out 
to be #3 ;(



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Question - foreach.

2010-06-10 Thread Paul M Foster
On Thu, Jun 10, 2010 at 11:16:08AM -0400, tedd wrote:

 At 9:32 AM -0400 6/10/10, Paul M Foster wrote:
 On Thu, Jun 10, 2010 at 07:03:28AM -0400, tedd wrote:

   This is one of those questions that you can test very easily, just
  initialize an array and try it.

 +1

 This is Tedd's modus operandi. His website(s) are full of exactly this
 type of thing. And I have to agree. I can't count the number of
 questions I *haven't* asked on this list, because I built a page to test
 a particular concept. And this sort of activity (as opposed to just
 reading about something) really locks in your understanding of a
 concept.

 Paul

 Paul:

 Now, if I could get the old memory to lock in and remember it, it
 would be great!

 I spend much of my time thinking Did I do that before?

grin I know the feeling. I will say this, though. I have yet to figure
out, from your URLs, how your site(s) is/are organized. Maybe a reorg
would help?

Paul

-- 
Paul M. Foster

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] is ?= good?

2010-06-10 Thread Ahmed Mohsen
I know that i should use the full open tag in php ?php ? but i want to 
know if its good to use this tag ?=$name? instead of ?php echo $name ?


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Question - foreach.

2010-06-10 Thread Bob McConnell
From: Paul M Foster

 On Thu, Jun 10, 2010 at 11:16:08AM -0400, tedd wrote:

 At 9:32 AM -0400 6/10/10, Paul M Foster wrote:
 On Thu, Jun 10, 2010 at 07:03:28AM -0400, tedd wrote:


 Paul:

 Now, if I could get the old memory to lock in and remember it, it
 would be great!

 I spend much of my time thinking Did I do that before?
 
 grin I know the feeling. I will say this, though. I have yet to
figure
 out, from your URLs, how your site(s) is/are organized. Maybe a reorg
 would help?

ISTR there are three signs of old age. The first is loss of memory, but
I can never remember the other two.

Bob McConnell

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Redirect to

2010-06-10 Thread Ahmed Mohsen

Thanks for help.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] is ?= good?

2010-06-10 Thread Ashley Sheridan
On Fri, 2010-06-11 at 01:34 +0300, Ahmed Mohsen wrote:

 I know that i should use the full open tag in php ?php ? but i want to 
 know if its good to use this tag ?=$name? instead of ?php echo $name ?
 


Depends who you ask, there was a discussion of this on the list a while
back, and the result was pretty split 50/50. Personally I think it's a
bad idea, as those tags only work when short_tags are turned on, which
itself causes problems with outputting XML from PHP. Yes it saves a
little bit of typing, but with a decent IDE you can set up a shortcut
for that sort of thing anyway, negating the extra seconds spent on a
large project by typing the echo statement.

There is also a potential issue when you move your code to a different
server, as short tags are not enabled by default as of PHP 5.

But, like I said, if you ask someone else, you'll likely get a different
opinion on this issue.

If you're the only one using this code, and the server is in your
control, then it's down to what you prefer to use. If the codebase is
shared, or the hosting is not in your control (shared hosting, etc) then
it's probably best to stick to the regular ?php echo $name ? format.

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] Brandon Rampersad wants to chat

2010-06-10 Thread Ashley Sheridan
Please could you not send out these auto messages Brandon as I believe
this is the second time a message has hit both my email address and the
mailing list with a request for Google chat from you.

Thanks,
Ash
http://www.ashleysheridan.co.uk



On Thu, 2010-06-10 at 13:46 -0700, Brandon Rampersad wrote:

 ---
 
 Brandon Rampersad wants to stay in better touch using some of Google's
 coolest new
 products.
 
 If you already have Gmail or Google Talk, visit:
 http://mail.google.com/mail/b-b89a7a894d-87f44ca42c-QxVqdDj-Y-taKgwQ_V0g-Q8WRBY
 You'll need to click this link to be able to chat with Brandon Rampersad.
 
 To get Gmail - a free email account from Google with over 2,800 megabytes of
 storage - and chat with Brandon Rampersad, visit:
 http://mail.google.com/mail/a-b89a7a894d-87f44ca42c-QxVqdDj-Y-taKgwQ_V0g-Q8WRBY
 
 Gmail offers:
 - Instant messaging right inside Gmail
 - Powerful spam protection
 - Built-in search for finding your messages and a helpful way of organizing
   emails into conversations
 - No pop-up ads or untargeted banners - just text ads and related information
   that are relevant to the content of your messages
 
 All this, and its yours for free. But wait, there's more! By opening a Gmail
 account, you also get access to Google Talk, Google's instant messaging
 service:
 
 http://www.google.com/talk/
 
 Google Talk offers:
 - Web-based chat that you can use anywhere, without a download
 - A contact list that's synchronized with your Gmail account
 - Free, high quality PC-to-PC voice calls when you download the Google Talk
   client
 
 We're working hard to add new features and make improvements, so we might also
 ask for your comments and suggestions periodically. We appreciate your help in
 making our products even better!
 
 Thanks,
 The Google Team
 
 To learn more about Gmail and Google Talk, visit:
 http://mail.google.com/mail/help/about.html
 http://www.google.com/talk/about.html
 
 (If clicking the URLs in this message does not work, copy and paste them into
 the address bar of your browser).
 





[PHP] Brandon Rampersad wants to chat

2010-06-10 Thread Brandon Rampersad
---

Brandon Rampersad wants to stay in better touch using some of Google's
coolest new
products.

If you already have Gmail or Google Talk, visit:
http://mail.google.com/mail/b-b89a7a894d-87f44ca42c-QxVqdDj-Y-taKgwQ_V0g-Q8WRBY
You'll need to click this link to be able to chat with Brandon Rampersad.

To get Gmail - a free email account from Google with over 2,800 megabytes of
storage - and chat with Brandon Rampersad, visit:
http://mail.google.com/mail/a-b89a7a894d-87f44ca42c-QxVqdDj-Y-taKgwQ_V0g-Q8WRBY

Gmail offers:
- Instant messaging right inside Gmail
- Powerful spam protection
- Built-in search for finding your messages and a helpful way of organizing
  emails into conversations
- No pop-up ads or untargeted banners - just text ads and related information
  that are relevant to the content of your messages

All this, and its yours for free. But wait, there's more! By opening a Gmail
account, you also get access to Google Talk, Google's instant messaging
service:

http://www.google.com/talk/

Google Talk offers:
- Web-based chat that you can use anywhere, without a download
- A contact list that's synchronized with your Gmail account
- Free, high quality PC-to-PC voice calls when you download the Google Talk
  client

We're working hard to add new features and make improvements, so we might also
ask for your comments and suggestions periodically. We appreciate your help in
making our products even better!

Thanks,
The Google Team

To learn more about Gmail and Google Talk, visit:
http://mail.google.com/mail/help/about.html
http://www.google.com/talk/about.html

(If clicking the URLs in this message does not work, copy and paste them into
the address bar of your browser).

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] is ?= good?

2010-06-10 Thread David Harkness
On Thu, Jun 10, 2010 at 3:34 PM, Ahmed Mohsen mre...@gmail.com wrote:

 I know that i should use the full open tag in php ?php ? but i want to
 know if its good to use this tag ?=$name? instead of ?php echo $name ?


According to some PHP 6 will remove support for short tags. They won't be
disabled by default--the feature simply won't exist.

http://www.slideshare.net/thinkphp/php-53-and-php-6-a-look-ahead

David


Re: [PHP] is ?= good?

2010-06-10 Thread Daniel Brown
On Thu, Jun 10, 2010 at 19:35, David Harkness davi...@highgearmedia.com wrote:

 According to some PHP 6 will remove support for short tags. They won't be
 disabled by default--the feature simply won't exist.

    http://www.slideshare.net/thinkphp/php-53-and-php-6-a-look-ahead

I don't know why Stefan said that, but in fairness, that slideshow
is two years old.  You'll still see short_open_tags, but you'll no
longer have ASP-style tags or the little-known script language=PHP
options available.

-- 
/Daniel P. Brown
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
We now offer SAME-DAY SETUP on a new line of servers!

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] is ?= good?

2010-06-10 Thread Ahmed Mohsen

On 6/11/2010 2:49 AM, Daniel Brown wrote:

On Thu, Jun 10, 2010 at 19:35, David Harknessdavi...@highgearmedia.com  wrote:


According to some PHP 6 will remove support for short tags. They won't be
disabled by default--the feature simply won't exist.

http://www.slideshare.net/thinkphp/php-53-and-php-6-a-look-ahead


 I don't know why Stefan said that, but in fairness, that slideshow
is two years old.  You'll still see short_open_tags, but you'll no
longer have ASP-style tags or the little-knownscript language=PHP
options available.


It still much safer to use the full tag to avoid any errors in the future

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] is ?= good?

2010-06-10 Thread David Harkness
On Thu, Jun 10, 2010 at 4:49 PM, Daniel Brown danbr...@php.net wrote:

 You'll still see short_open_tags,


That's good to hear. Not that we're in any rush to jump into PHP6 given that
we're only just now *close* to deploying 5.3.


 but you'll no
 longer have ASP-style tags or the little-known script language=PHP
 options available.


Heh, that's funny since that old slideshow said that script language=PHP
would always be an option. I've never seen it myself so I'm not too worried.
;)

David


[PHP] PHP -r, -a and .php return different results based upon or ' marks !? [BUG]

2010-06-10 Thread Daevid Vincent
Chew on this...

develo...@mypse:~$ cat ./md5test.php
#!/usr/bin/php
?php
$password = '12345678';
echo md5(strtoupper($password));
echo \n;
echo md5(strtoupper('12345678'));
echo \n;

$password = '$12345678';
echo md5(strtoupper($password));
echo \n;
echo md5(strtoupper('$12345678'));
echo \n;
?

develo...@mypse:~$ ./md5test.php
25d55ad283aa400af464c76d713c07ad
25d55ad283aa400af464c76d713c07ad
2d05c0e3d6d22343123eae7f5678e34c
2d05c0e3d6d22343123eae7f5678e34c

develo...@mypse:~$ php -r echo md5(strtoupper('12345678'));
25d55ad283aa400af464c76d713c07ad

develo...@mypse:~$ php -a
Interactive shell
php  echo md5(strtoupper('$12345678'));
2d05c0e3d6d22343123eae7f5678e34c

develo...@mypse:~$ php -r echo md5(strtoupper('$12345678'));
b3275960d68fda9d831facc0426c3bbc

Why is the -r command line version different?

man php:

   Using parameter -r you can directly execute  PHP  code  simply  as
you
   would do inside a .php file when using the eval() function.

develo...@mypse:~$ php -v
PHP 5.2.4-2ubuntu5.10 with Suhosin-Patch 0.9.6.2 (cli) (built: Jan  6 2010
22:01:14)
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies

Then I tried it again on two different servers with the same result:

PHP 5.2.6-2ubuntu4.6 with Suhosin-Patch 0.9.6.2 (cli) (built: Jan  6 2010
22:03:33)
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies

PHP 5.3.2-1ubuntu4.2 with Suhosin-Patch (cli) (built: May 13 2010 20:01:00)

Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies

So now it get's more interesting...

A co-worker suggested to reverse the quotes:

develo...@mypse:~$ php -r 'echo md5(strtoupper($12345678));'
2d05c0e3d6d22343123eae7f5678e34c

Note the use of the single and double quotes are reversed. This gives me
the RIGHT checksum.

To me this version is syntactically wrong because the  would indicate in
normal PHP to pre-parse the literal $12345678 and treat $1 as some kind of
variable or something. Whereas a ' says use the literal AS IS.

Not to mention that it is completely confusing that -r gives different
results than -a and using it in a .php file all together. 

IF quotes are a factor (as they seem to be), then the -r PHP
behind-the-scenes code should flip them around or something so the
developer doesn't have to be concerned with this edge case nonsense. 

Sanity would dictate that all ways of executing the SAME PHP code would
give the SAME results.

*sigh*


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] is ?= good?

2010-06-10 Thread Daevid Vincent
I use them ALL the time. MUCH cleaner IMHO than the alternatives.

And *IF* someday it is ever depricated, it's trival to:

 s/?=/? echo/g

Don't let 'em scare ya!

 -Original Message-
 From: Ahmed Mohsen [mailto:mre...@gmail.com] 
 Sent: Thursday, June 10, 2010 3:35 PM
 To: php-general@lists.php.net
 Subject: [PHP] is ?= good?
 
 I know that i should use the full open tag in php ?php ? 
 but i want to 
 know if its good to use this tag ?=$name? instead of ?php 
 echo $name ?
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP -r, -a and .php return different results based upon or ' marks !? [BUG]

2010-06-10 Thread Simon J Welsh

On 11/06/2010, at 12:49 PM, Daevid Vincent wrote:

 Chew on this...
 
 develo...@mypse:~$ cat ./md5test.php
 #!/usr/bin/php
 ?php
 $password = '12345678';
 echo md5(strtoupper($password));
 echo \n;
 echo md5(strtoupper('12345678'));
 echo \n;
 
 $password = '$12345678';
 echo md5(strtoupper($password));
 echo \n;
 echo md5(strtoupper('$12345678'));
 echo \n;
 ?
 
 develo...@mypse:~$ ./md5test.php
 25d55ad283aa400af464c76d713c07ad
 25d55ad283aa400af464c76d713c07ad
 2d05c0e3d6d22343123eae7f5678e34c
 2d05c0e3d6d22343123eae7f5678e34c
 
 develo...@mypse:~$ php -r echo md5(strtoupper('12345678'));
 25d55ad283aa400af464c76d713c07ad
 
 develo...@mypse:~$ php -a
 Interactive shell
 php  echo md5(strtoupper('$12345678'));
 2d05c0e3d6d22343123eae7f5678e34c
 
 develo...@mypse:~$ php -r echo md5(strtoupper('$12345678'));
 b3275960d68fda9d831facc0426c3bbc
 
 Why is the -r command line version different?
 
 man php:
 
   Using parameter -r you can directly execute  PHP  code  simply  as
 you
   would do inside a .php file when using the eval() function.
 
 develo...@mypse:~$ php -v
 PHP 5.2.4-2ubuntu5.10 with Suhosin-Patch 0.9.6.2 (cli) (built: Jan  6 2010
 22:01:14)
 Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
 
 Then I tried it again on two different servers with the same result:
 
 PHP 5.2.6-2ubuntu4.6 with Suhosin-Patch 0.9.6.2 (cli) (built: Jan  6 2010
 22:03:33)
 Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
 
 PHP 5.3.2-1ubuntu4.2 with Suhosin-Patch (cli) (built: May 13 2010 20:01:00)
 
 Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
 
 So now it get's more interesting...
 
 A co-worker suggested to reverse the quotes:
 
 develo...@mypse:~$ php -r 'echo md5(strtoupper($12345678));'
 2d05c0e3d6d22343123eae7f5678e34c
 
 Note the use of the single and double quotes are reversed. This gives me
 the RIGHT checksum.
 
 To me this version is syntactically wrong because the  would indicate in
 normal PHP to pre-parse the literal $12345678 and treat $1 as some kind of
 variable or something. Whereas a ' says use the literal AS IS.
 
 Not to mention that it is completely confusing that -r gives different
 results than -a and using it in a .php file all together. 
 
 IF quotes are a factor (as they seem to be), then the -r PHP
 behind-the-scenes code should flip them around or something so the
 developer doesn't have to be concerned with this edge case nonsense. 
 
 Sanity would dictate that all ways of executing the SAME PHP code would
 give the SAME results.
 
 *sigh*

It's your shell doing what it's supposed to, by replacing $12345678, when the 
entire string's in double quotes, with the contents of the shell variable 
12345678 (most likely nothing), so all that PHP sees is: echo 
md5(strtoupper(''));
---
Simon Welsh
Admin of http://simon.geek.nz/

Who said Microsoft never created a bug-free program? The blue screen never, 
ever crashes!

http://www.thinkgeek.com/brain/gimme.cgi?wid=81d520e5e





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP -r, -a and .php return different results based upon or ' marks !? [BUG]

2010-06-10 Thread Ashley Sheridan
On Thu, 2010-06-10 at 17:49 -0700, Daevid Vincent wrote:

 Chew on this...
 
 develo...@mypse:~$ cat ./md5test.php
 #!/usr/bin/php
 ?php
 $password = '12345678';
 echo md5(strtoupper($password));
 echo \n;
 echo md5(strtoupper('12345678'));
 echo \n;
 
 $password = '$12345678';
 echo md5(strtoupper($password));
 echo \n;
 echo md5(strtoupper('$12345678'));
 echo \n;
 ?
 
 develo...@mypse:~$ ./md5test.php
 25d55ad283aa400af464c76d713c07ad
 25d55ad283aa400af464c76d713c07ad
 2d05c0e3d6d22343123eae7f5678e34c
 2d05c0e3d6d22343123eae7f5678e34c
 
 develo...@mypse:~$ php -r echo md5(strtoupper('12345678'));
 25d55ad283aa400af464c76d713c07ad
 
 develo...@mypse:~$ php -a
 Interactive shell
 php  echo md5(strtoupper('$12345678'));
 2d05c0e3d6d22343123eae7f5678e34c
 
 develo...@mypse:~$ php -r echo md5(strtoupper('$12345678'));
 b3275960d68fda9d831facc0426c3bbc
 
 Why is the -r command line version different?
 
 man php:
 
Using parameter -r you can directly execute  PHP  code  simply  as
 you
would do inside a .php file when using the eval() function.
 
 develo...@mypse:~$ php -v
 PHP 5.2.4-2ubuntu5.10 with Suhosin-Patch 0.9.6.2 (cli) (built: Jan  6 2010
 22:01:14)
 Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
 
 Then I tried it again on two different servers with the same result:
 
 PHP 5.2.6-2ubuntu4.6 with Suhosin-Patch 0.9.6.2 (cli) (built: Jan  6 2010
 22:03:33)
 Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
 
 PHP 5.3.2-1ubuntu4.2 with Suhosin-Patch (cli) (built: May 13 2010 20:01:00)
 
 Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
 
 So now it get's more interesting...
 
 A co-worker suggested to reverse the quotes:
 
 develo...@mypse:~$ php -r 'echo md5(strtoupper($12345678));'
 2d05c0e3d6d22343123eae7f5678e34c
 
 Note the use of the single and double quotes are reversed. This gives me
 the RIGHT checksum.
 
 To me this version is syntactically wrong because the  would indicate in
 normal PHP to pre-parse the literal $12345678 and treat $1 as some kind of
 variable or something. Whereas a ' says use the literal AS IS.
 
 Not to mention that it is completely confusing that -r gives different
 results than -a and using it in a .php file all together. 
 
 IF quotes are a factor (as they seem to be), then the -r PHP
 behind-the-scenes code should flip them around or something so the
 developer doesn't have to be concerned with this edge case nonsense. 
 
 Sanity would dictate that all ways of executing the SAME PHP code would
 give the SAME results.
 
 *sigh*
 
 


I believe that when you're running the PHP with the -r, the quotation
marks are treated as Bash (or whichever shell you're using) quotes, and
so the variable is possibly being parsed as an empty string value, which
is why reversing the quotes is having the right effect.

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] Question - foreach.

2010-06-10 Thread David McGlone
On Thursday 10 June 2010 11:16:08 tedd wrote:
 At 9:32 AM -0400 6/10/10, Paul M Foster wrote:
 On Thu, Jun 10, 2010 at 07:03:28AM -0400, tedd wrote:
This is one of those questions that you can test very easily, just
   
   initialize an array and try it.
 
 +1
 
 This is Tedd's modus operandi. His website(s) are full of exactly this
 type of thing. And I have to agree. I can't count the number of
 questions I *haven't* asked on this list, because I built a page to test
 a particular concept. And this sort of activity (as opposed to just
 reading about something) really locks in your understanding of a
 concept.
 
 Paul
 
 Paul:
 
 Now, if I could get the old memory to lock in and remember it, it
 would be great!
 
 I spend much of my time thinking Did I do that before?

Looks like you and I are in the same boat! My memory these days has went to 
the dumps.

Although I do the same thing Paul does to actually grasp a more in depth 
understanding of something, sometimes in a day or two it's often forgotten.

-- 
Blessings,
David M.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] is ?= good?

2010-06-10 Thread Daniel P. Brown
On Thu, Jun 10, 2010 at 20:53, Daevid Vincent dae...@daevid.com wrote:
 I use them ALL the time. MUCH cleaner IMHO than the alternatives.

 And *IF* someday it is ever depricated, it's trival to:

         s/?=/? echo/g

Right.  Because if we do away with short_open_tags, the fix is to
replace them all with short_open_tags.  ;-P





P.S. - You may want to sed your vim.  ;-P


-- 
/Daniel P. Brown
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
We now offer SAME-DAY SETUP on a new line of servers!

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] is ?= good?

2010-06-10 Thread Floyd Resler


On Jun 10, 2010, at 8:53 PM, Daevid Vincent wrote:


I use them ALL the time. MUCH cleaner IMHO than the alternatives.

And *IF* someday it is ever depricated, it's trival to:

 s/?=/? echo/g

Don't let 'em scare ya!


-Original Message-
From: Ahmed Mohsen [mailto:mre...@gmail.com]
Sent: Thursday, June 10, 2010 3:35 PM
To: php-general@lists.php.net
Subject: [PHP] is ?= good?

I know that i should use the full open tag in php ?php ?
but i want to
know if its good to use this tag ?=$name? instead of ?php
echo $name ?

--  
PHP General Mailing List (http://www.php.net/)

To unsubscribe, visit: http://www.php.net/unsub.php




--  
PHP General Mailing List (http://www.php.net/)

To unsubscribe, visit: http://www.php.net/unsub.php


I have to agree that ?= is much cleaner and I use them all the time  
as well.


Take care,
Floyd


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php