php-general Digest 3 Apr 2012 06:13:26 -0000 Issue 7758

2012-04-03 Thread php-general-digest-help

php-general Digest 3 Apr 2012 06:13:26 - Issue 7758

Topics (messages 317428 through 317435):

Re: Thinking out loud - a continuation...
317428 by: Jay Blanchard
317429 by: Matijn Woudt
317430 by: Robert Cummings

Re: Could apc_fetch return a pointer to data in shared memory ?
317431 by: Stuart Dallas
317435 by: Simon

Re: Variable representation
317432 by: tamouse mailing lists

Adding Rows In PHPMYADMIN
317433 by: Karl James
317434 by: Tommy Pham

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---
[snip]
 function getTiersJson( $company )
 {
$tiers = getTiers( $company );
$json = JSON_encode( $tiers );
 }
 
 $tiersJson = getTiersJson( 1 );
 
 ?
 
 This will output JSON with the following structure:
 
[/snip]

OK, now I know I am being dense - but don't I have to add return $json; to 
getTiersJson() ?---End Message---
---BeginMessage---
On Mon, Apr 2, 2012 at 10:36 PM, Jay Blanchard
jay.blanch...@sigmaphinothing.org wrote:
 [snip]
 function getTiersJson( $company )
 {
    $tiers = getTiers( $company );
    $json = JSON_encode( $tiers );
 }

 $tiersJson = getTiersJson( 1 );

 ?

 This will output JSON with the following structure:

 [/snip]

 OK, now I know I am being dense - but don't I have to add return $json; to 
 getTiersJson() ?

Of course ;)
---End Message---
---BeginMessage---

On 12-04-02 04:36 PM, Jay Blanchard wrote:

[snip]

function getTiersJson( $company )
{
$tiers = getTiers( $company );
$json = JSON_encode( $tiers );
}

$tiersJson = getTiersJson( 1 );

?

This will output JSON with the following structure:


[/snip]

OK, now I know I am being dense - but don't I have to add return $json; to 
getTiersJson() ?


yeah, *lol* in my testing I had a print_r() in the getTiersJson() so 
didn't notice I wasn't returning since I didn't do anything with the 
captured value (null without a proper return).


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.
---End Message---
---BeginMessage---
On 2 Apr 2012, at 15:37, Simon wrote:

 On 2 April 2012 14:27, Stuart Dallas stu...@3ft9.com wrote:
 On 2 Apr 2012, at 14:12, Simon wrote:
 
  Thanks Maciek
 
  On 2 April 2012 10:37, Maciek Sokolewicz 
  maciek.sokolew...@gmail.comwrote:
 
  On 02-04-2012 10:12, Simon wrote:
 
  Thanks Simon. you got my hopes up there for a second.
 
  From the php docs page:
 
  Critics further argue that it is pointless to use a Singleton in a Shared
 
  Nothing Architecture like PHP where objects are uniquewithin the Request
  only anyways.
 
  I want the the singleton class to be global to the entire application (ie
  shared by reference across all requests). I'd agree with the above
  critics that if you have to instantiate your singleton for each request,
  it's rather pointless.
 
  Well, that's simply not possible due to the shared nothing paradigm.
  If you want to share, you need to either share it via another medium (such
  as a database, as has been suggested a dozen times already) or switch to a
  different language.
 
 
 
  PHP is based on this paradigm, and you should not expect of it to violate
  it just because you want to do things a certain way, which is not the PHP
  way.
 
 
  The existence of memcached, shm and apc_fetch tell me that PHP already
  accepts the need for sharing data between processes. All I'm arguing for is
  the ability to share the data by reference rather than by copy.
 
 
 As already mentioned several times the closest you will get is shared memory 
 (as used by APC), but you can't access that by reference because shared 
 read/write resources need controlled access for stability.
 
 I know. I understand that (and the issues with locking that might arise if 
 truly shared memory was available).
 
 I can't find any material that explains how the .net framework implements 
 application variables. You mentioned earlier that you *know* that when you 
 access them you do so by reference. Do you have a source for this knowledge 
 or is it some sort of sixth sense?
 
 Source: 10+ years as an ASP and ASP.NET developer. 

Wow. As knowledge goes that's up there with I believe it therefore it is.

 Having looked for documentation, I agree, it's utterly terrible. It's as if 
 even Microsoft themselves don't fully understand the advantages that 
 application variables give them over the competition. (Though they're hardly 
 likely to be forthcoming about helping others implement similar features).
 
 

php-general Digest 3 Apr 2012 19:16:36 -0000 Issue 7759

2012-04-03 Thread php-general-digest-help

php-general Digest 3 Apr 2012 19:16:36 - Issue 7759

Topics (messages 317436 through 317437):

Re: learning resources for PHP
317436 by: Daniel Brown

Re: Node.PHP
317437 by: Joseph Moniz

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---
On Mon, Apr 2, 2012 at 23:53, Tim Dunphy bluethu...@gmail.com wrote:
 Hello list,

  I am quite sure that you've heard this question at least a few times
 before. :) But I have been dabbling a bit in PHP for years and I've
 decided that its' high time that became serious about getting a solid
 grounding in it. Currently I work as a Sysadmin and have modest but
 reliable skills in bash and perl. But I consider PHP more of an
 artform and I really need to 'pick up a brush and start painting' so
 to speak.

  So what I was wondering what websites, and books you'd recommend to
 someone who (for all intents and purpose) is just starting out.

  On my hit list of things to learn are basic php / database
 interaction (mysql mainly).. then how to accelerate php interraction
 through memcache.. and eventually one I have all that down onto using
 some of the NoSQLs (mongo/cassandra/membase, etc).

 Thanks!

 -tim


 --
 GPG me!!

 gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B

Your question is better asked (and will certainly be better
answered) on the general list at php-gene...@lists.php.net, Tim, and
I've CC'd the list for you.  If you haven't already, please subscribe
to that list to ensure you receive all the responses.

-- 
/Daniel P. Brown
Network Infrastructure Manager
http://www.php.net/
---End Message---
---BeginMessage---
On Fri, Mar 30, 2012 at 5:56 PM, German Geek geek...@gmail.com wrote:
 Maybe stupid question, but is node.php really necessary? If you can program
 PHP and it performs better than node.js, why would you need to have another
 wrapper around things. Why not just program normal PHP?

This is normal PHP in the same sense that node.js is normal
javascript, python-tornado is normal python and ruby-event-machine is
normal ruby. The only difference as stated by micheal was the async
IO.

On Fri, Mar 30, 2012 at 6:33 PM, Michael Save
savetheinter...@omegasdg.com wrote:
 Also, I kind of doubt you can outperform node.js with standard PHP.

On Sat, Mar 31, 2012 at 9:37 AM, Daniel Brown danbr...@php.net wrote:
 On Fri, Mar 30, 2012 at 21:33, Michael Save
 savetheinter...@omegasdg.com wrote:
 Because normal PHP is not asynchronous.

 Also, I kind of doubt you can outperform node.js with standard PHP.

    Your doubts are indeed well-grounded.  Using node.js (indeed,
 V8-based apps in general) are compiled as native machine code, which
 don't require the added overhead of a parser, such as PHP.

This has been an on the side just for fun project for me mostly and as
such i originally had the same performance assumptions as stated in
this thread. Basically i was writing this to get familar with php
internals and to understand what goes into designing such a system.

You can imagine my surprise when i ran bench marks against the example
server against an equivelant node.js http server and the node.php
implementation was able to respond to twice as many requests per
second (14k req/s) then node.js could (7k req/s). Though i would take
this with a grain of salt as the benchmark is largely unfair seeing
how node.js is much more feature complete and hardend from production
use. Never the less, i was absolutely shocked that this completely
unoptomized and memory leaky node.php implementation i hacked together
in one night was able to run circles around node.js in naive
benchmarks.

So i was absolutely confused to the performance boost with php so i
started poking around asking people in various freenode channels if
they had any hypothesis on why node.php was able to perform against
node.js.

I stumbled across a similar project to create a node.lua
implemantation called luvit ( http://www.luvit.io ) and it also
boasted the same exact performance boost vs node.js, thats is luvit
was able to do 2x the requests as node.js in the same amount of time.

From my exploration on nodes 1/2x performance vs node.php and luvit
(node.lua) it turns out that V8 is fast only when it has to stay in JS
mode. The problem with node like systems is the JS to native code
boundary must be crossed several times to perform IO. So nodejs-core
get's some of it's best performance boosts from reducing the amount of
times JS has to call out to C++. The unfortunate detail is that
node.js like systems get their power from doing lots of IO and every
IO operation has to call out to C/C++ so node.js performance really
drags around this gotcha in V8.

I hold out some hope for 

Re: [PHP] Could apc_fetch return a pointer to data in shared memory ?

2012-04-03 Thread Simon
On 2 April 2012 22:25, Stuart Dallas stu...@3ft9.com wrote:

 On 2 Apr 2012, at 15:37, Simon wrote:

  On 2 April 2012 14:27, Stuart Dallas stu...@3ft9.com wrote:
  On 2 Apr 2012, at 14:12, Simon wrote:
 
   Thanks Maciek
  
   On 2 April 2012 10:37, Maciek Sokolewicz maciek.sokolew...@gmail.com
 wrote:
  
   On 02-04-2012 10:12, Simon wrote:
  
   Thanks Simon. you got my hopes up there for a second.
  
   From the php docs page:
  
   Critics further argue that it is pointless to use a Singleton in a
 Shared
  
   Nothing Architecture like PHP where objects are uniquewithin the
 Request
   only anyways.
  
   I want the the singleton class to be global to the entire
 application (ie
   shared by reference across all requests). I'd agree with the above
   critics that if you have to instantiate your singleton for each
 request,
   it's rather pointless.
  
   Well, that's simply not possible due to the shared nothing
 paradigm.
   If you want to share, you need to either share it via another medium
 (such
   as a database, as has been suggested a dozen times already) or
 switch to a
   different language.
  
  
  
   PHP is based on this paradigm, and you should not expect of it to
 violate
   it just because you want to do things a certain way, which is not
 the PHP
   way.
  
  
   The existence of memcached, shm and apc_fetch tell me that PHP already
   accepts the need for sharing data between processes. All I'm arguing
 for is
   the ability to share the data by reference rather than by copy.
 
 
  As already mentioned several times the closest you will get is shared
 memory (as used by APC), but you can't access that by reference because
 shared read/write resources need controlled access for stability.
 
  I know. I understand that (and the issues with locking that might arise
 if truly shared memory was available).
 
  I can't find any material that explains how the .net framework
 implements application variables. You mentioned earlier that you *know*
 that when you access them you do so by reference. Do you have a source for
 this knowledge or is it some sort of sixth sense?
 
  Source: 10+ years as an ASP and ASP.NET developer.

 Wow. As knowledge goes that's up there with I believe it therefore it is.


I don't understand your point.



  Having looked for documentation, I agree, it's utterly terrible. It's as
 if even Microsoft themselves don't fully understand the advantages that
 application variables give them over the competition. (Though they're
 hardly likely to be forthcoming about helping others implement similar
 features).
 
  Here's some stuff I did find:
 
 
 http://www.codeproject.com/Articles/87316/A-walkthrough-to-Application-State#e
  This article explains basically how application variables work. It
 doesn't specifically mention passing by reference but it discusses thread
 safety at some length so you might infer that implies passing by reference.

 can cause performance overhead if it is heavy


You certainly have to be careful how you use it (as you do any tool).

| And you want to store petabytes of data in there. Smart.

No, I want to store 50 - 200Mb.
At some point in the somewhat distant future I can imagine larger amounts
of shared storage between required. Up to and including petabytes of data
when such large amounts of RAM become practical.

This does not have to cause overhead. The author was suggesting caution to
protect people who aren't sure what they're doing. This can be done with
no performance overhead (so long as you have the physical RAM).



 Anyway, that page says nothing about whether it's accessed by reference.
 It implies that writes are atomic, which in turn implies that there is
 something in the background controlling write access to the data.

 As for reading the data being done via references there is nothing in that
 article to suggest that.

  http://msdn.microsoft.com/en-us/library/ff650849.aspx
  Here is a more technical discussion about the singleton class is
 implemented in .NET. Application variables are provided by an instance of a
 singleton class (the HttpApplication class).

 Looks no different to the way you'd implement a singleton in PHP (as
 expected - as a concept it doesn't generally change between languages).
 Just because the HttpApplication class is a singleton doesn't mean that
 when you request data from it you get it by reference.


Could we just for the sake of argument, just accept that it does actually
pass by reference between threads, but not between processes ? It does - is
that really so hard to believe ?



 
 http://stackoverflow.com/questions/1132373/do-asp-net-application-variables-pass-by-reference-or-value
  Stack overflow question from someone actually wanting to get a *copy* of
 an application variable rather than a reference.

 According to that page scalar values are returned by value, objects are
 returned as a copy of the reference. Based on that, it would appear that
 you are correct as far as objects 

[PHP] Re: learning resources for PHP

2012-04-03 Thread Daniel Brown
On Mon, Apr 2, 2012 at 23:53, Tim Dunphy bluethu...@gmail.com wrote:
 Hello list,

  I am quite sure that you've heard this question at least a few times
 before. :) But I have been dabbling a bit in PHP for years and I've
 decided that its' high time that became serious about getting a solid
 grounding in it. Currently I work as a Sysadmin and have modest but
 reliable skills in bash and perl. But I consider PHP more of an
 artform and I really need to 'pick up a brush and start painting' so
 to speak.

  So what I was wondering what websites, and books you'd recommend to
 someone who (for all intents and purpose) is just starting out.

  On my hit list of things to learn are basic php / database
 interaction (mysql mainly).. then how to accelerate php interraction
 through memcache.. and eventually one I have all that down onto using
 some of the NoSQLs (mongo/cassandra/membase, etc).

 Thanks!

 -tim


 --
 GPG me!!

 gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B

Your question is better asked (and will certainly be better
answered) on the general list at php-general@lists.php.net, Tim, and
I've CC'd the list for you.  If you haven't already, please subscribe
to that list to ensure you receive all the responses.

-- 
/Daniel P. Brown
Network Infrastructure Manager
http://www.php.net/

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



Re: [PHP] Node.PHP

2012-04-03 Thread Joseph Moniz
On Fri, Mar 30, 2012 at 5:56 PM, German Geek geek...@gmail.com wrote:
 Maybe stupid question, but is node.php really necessary? If you can program
 PHP and it performs better than node.js, why would you need to have another
 wrapper around things. Why not just program normal PHP?

This is normal PHP in the same sense that node.js is normal
javascript, python-tornado is normal python and ruby-event-machine is
normal ruby. The only difference as stated by micheal was the async
IO.

On Fri, Mar 30, 2012 at 6:33 PM, Michael Save
savetheinter...@omegasdg.com wrote:
 Also, I kind of doubt you can outperform node.js with standard PHP.

On Sat, Mar 31, 2012 at 9:37 AM, Daniel Brown danbr...@php.net wrote:
 On Fri, Mar 30, 2012 at 21:33, Michael Save
 savetheinter...@omegasdg.com wrote:
 Because normal PHP is not asynchronous.

 Also, I kind of doubt you can outperform node.js with standard PHP.

    Your doubts are indeed well-grounded.  Using node.js (indeed,
 V8-based apps in general) are compiled as native machine code, which
 don't require the added overhead of a parser, such as PHP.

This has been an on the side just for fun project for me mostly and as
such i originally had the same performance assumptions as stated in
this thread. Basically i was writing this to get familar with php
internals and to understand what goes into designing such a system.

You can imagine my surprise when i ran bench marks against the example
server against an equivelant node.js http server and the node.php
implementation was able to respond to twice as many requests per
second (14k req/s) then node.js could (7k req/s). Though i would take
this with a grain of salt as the benchmark is largely unfair seeing
how node.js is much more feature complete and hardend from production
use. Never the less, i was absolutely shocked that this completely
unoptomized and memory leaky node.php implementation i hacked together
in one night was able to run circles around node.js in naive
benchmarks.

So i was absolutely confused to the performance boost with php so i
started poking around asking people in various freenode channels if
they had any hypothesis on why node.php was able to perform against
node.js.

I stumbled across a similar project to create a node.lua
implemantation called luvit ( http://www.luvit.io ) and it also
boasted the same exact performance boost vs node.js, thats is luvit
was able to do 2x the requests as node.js in the same amount of time.

From my exploration on nodes 1/2x performance vs node.php and luvit
(node.lua) it turns out that V8 is fast only when it has to stay in JS
mode. The problem with node like systems is the JS to native code
boundary must be crossed several times to perform IO. So nodejs-core
get's some of it's best performance boosts from reducing the amount of
times JS has to call out to C++. The unfortunate detail is that
node.js like systems get their power from doing lots of IO and every
IO operation has to call out to C/C++ so node.js performance really
drags around this gotcha in V8.

I hold out some hope for native PHP performance tough. If some one
were to invest the time into making a solid JIT based interpreter for
PHP i'm fairly confident based on language characteristics and the
performance characteristics associated with them that a PHP-JIT
implementation would be able to leave V8 in the dust. Mostly due to
explicit lexical scoping in PHP that would offset the Hidden-Class
overhead of V8.

In terms of PHP-JITs Facebook has already done some initial work on
such a VM, they call it, not surprisingly, hip-hop-virtual-machine (
http://www.facebook.com/note.php?note_id=10150415177928920 ) and it
already doing almost no optimizations is closer to performance of
compiled PHP via hiphop then it is to interpreted PHP via the de facto
interpreter.

- Joseph Moniz



  With that
 said, compiling PHP (such as with HopHop) would give at least
 comparable performance results.

    Still, all in all, I would never discourage someone doing a
 'node.php' application.  While its performance may not be quite as
 good speed-wise, that doesn't mean it can't become more robust, more
 generally-applicable, or even just find niche uses.  I've written
 numerous socket servers in PHP for a variety of clients and uses,
 where they made sense (speed of deployment, ease of code-management by
 a number of developers who don't know C, et cetera).  I can easily see
 where this could add value.

 --
 /Daniel P. Brown
 Network Infrastructure Manager
 http://www.php.net/

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



Re: [PHP] Node.PHP

2012-04-03 Thread Joseph Moniz
*bad link in last post

http://luvit.io/


-Joseph Moniz



On Tue, Apr 3, 2012 at 12:16 PM, Joseph Moniz joseph.mo...@gmail.com wrote:
 On Fri, Mar 30, 2012 at 5:56 PM, German Geek geek...@gmail.com wrote:
 Maybe stupid question, but is node.php really necessary? If you can program
 PHP and it performs better than node.js, why would you need to have another
 wrapper around things. Why not just program normal PHP?

 This is normal PHP in the same sense that node.js is normal
 javascript, python-tornado is normal python and ruby-event-machine is
 normal ruby. The only difference as stated by micheal was the async
 IO.

 On Fri, Mar 30, 2012 at 6:33 PM, Michael Save
 savetheinter...@omegasdg.com wrote:
 Also, I kind of doubt you can outperform node.js with standard PHP.

 On Sat, Mar 31, 2012 at 9:37 AM, Daniel Brown danbr...@php.net wrote:
 On Fri, Mar 30, 2012 at 21:33, Michael Save
 savetheinter...@omegasdg.com wrote:
 Because normal PHP is not asynchronous.

 Also, I kind of doubt you can outperform node.js with standard PHP.

    Your doubts are indeed well-grounded.  Using node.js (indeed,
 V8-based apps in general) are compiled as native machine code, which
 don't require the added overhead of a parser, such as PHP.

 This has been an on the side just for fun project for me mostly and as
 such i originally had the same performance assumptions as stated in
 this thread. Basically i was writing this to get familar with php
 internals and to understand what goes into designing such a system.

 You can imagine my surprise when i ran bench marks against the example
 server against an equivelant node.js http server and the node.php
 implementation was able to respond to twice as many requests per
 second (14k req/s) then node.js could (7k req/s). Though i would take
 this with a grain of salt as the benchmark is largely unfair seeing
 how node.js is much more feature complete and hardend from production
 use. Never the less, i was absolutely shocked that this completely
 unoptomized and memory leaky node.php implementation i hacked together
 in one night was able to run circles around node.js in naive
 benchmarks.

 So i was absolutely confused to the performance boost with php so i
 started poking around asking people in various freenode channels if
 they had any hypothesis on why node.php was able to perform against
 node.js.

 I stumbled across a similar project to create a node.lua
 implemantation called luvit ( http://www.luvit.io ) and it also
 boasted the same exact performance boost vs node.js, thats is luvit
 was able to do 2x the requests as node.js in the same amount of time.

 From my exploration on nodes 1/2x performance vs node.php and luvit
 (node.lua) it turns out that V8 is fast only when it has to stay in JS
 mode. The problem with node like systems is the JS to native code
 boundary must be crossed several times to perform IO. So nodejs-core
 get's some of it's best performance boosts from reducing the amount of
 times JS has to call out to C++. The unfortunate detail is that
 node.js like systems get their power from doing lots of IO and every
 IO operation has to call out to C/C++ so node.js performance really
 drags around this gotcha in V8.

 I hold out some hope for native PHP performance tough. If some one
 were to invest the time into making a solid JIT based interpreter for
 PHP i'm fairly confident based on language characteristics and the
 performance characteristics associated with them that a PHP-JIT
 implementation would be able to leave V8 in the dust. Mostly due to
 explicit lexical scoping in PHP that would offset the Hidden-Class
 overhead of V8.

 In terms of PHP-JITs Facebook has already done some initial work on
 such a VM, they call it, not surprisingly, hip-hop-virtual-machine (
 http://www.facebook.com/note.php?note_id=10150415177928920 ) and it
 already doing almost no optimizations is closer to performance of
 compiled PHP via hiphop then it is to interpreted PHP via the de facto
 interpreter.

 - Joseph Moniz



   With that
 said, compiling PHP (such as with HopHop) would give at least
 comparable performance results.

    Still, all in all, I would never discourage someone doing a
 'node.php' application.  While its performance may not be quite as
 good speed-wise, that doesn't mean it can't become more robust, more
 generally-applicable, or even just find niche uses.  I've written
 numerous socket servers in PHP for a variety of clients and uses,
 where they made sense (speed of deployment, ease of code-management by
 a number of developers who don't know C, et cetera).  I can easily see
 where this could add value.

 --
 /Daniel P. Brown
 Network Infrastructure Manager
 http://www.php.net/

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



[PHP] To ? or not to ?

2012-04-03 Thread Tedd Sperling
Hi gang:

Let me start a religious war -- should one end their scripts with ? or not?

After years of never having a problem with ending any of my scripts with ?, 
I found that several students in my class had scripts that did not produce the 
desired result even after they were given the scripts via highlight_file() to 
cut and paste.

As it turned out, several students copy/pasted the script with an addition 
whitespace after the ending ? and as such the scripts did not run as 
expected. You see, the scripts created image but apparently the image delivery 
method objected to the additional whitespace.

Does anyone have more examples of where scripts will fail IF they end with ? 
 (note the additional space)?

Cheers,

tedd

_
tedd.sperl...@gmail.com
http://sperling.com






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



Re: [PHP] To ? or not to ?

2012-04-03 Thread Stuart Dallas
On 3 Apr 2012, at 22:29, Tedd Sperling wrote:

 Let me start a religious war -- should one end their scripts with ? or not?
 
 After years of never having a problem with ending any of my scripts with 
 ?, I found that several students in my class had scripts that did not 
 produce the desired result even after they were given the scripts via 
 highlight_file() to cut and paste.
 
 As it turned out, several students copy/pasted the script with an addition 
 whitespace after the ending ? and as such the scripts did not run as 
 expected. You see, the scripts created image but apparently the image 
 delivery method objected to the additional whitespace.
 
 Does anyone have more examples of where scripts will fail IF they end with 
 ?  (note the additional space)?

Usually when setting headers after such a script has been included when output 
buffering is turned off. Personally I never put the closing ? in if it's at 
the end of the file because it's unnecessary and can cause issues if it's 
present, but it's personal preference more than anything else.

Ultimately you have to consider that there's a reason it's optional - things 
like that don't generally happen by accident. I remember Rasmus commenting on 
this style issue a few years back so a search of the archives should find an 
official position.

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/

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



Re: [PHP] To ? or not to ?

2012-04-03 Thread Mari Masuda

On Apr 3, 2012, at 2:29 PM, Tedd Sperling wrote:

 Hi gang:
 
 Let me start a religious war -- should one end their scripts with ? or not?
 
 After years of never having a problem with ending any of my scripts with 
 ?, I found that several students in my class had scripts that did not 
 produce the desired result even after they were given the scripts via 
 highlight_file() to cut and paste.
 
 As it turned out, several students copy/pasted the script with an addition 
 whitespace after the ending ? and as such the scripts did not run as 
 expected. You see, the scripts created image but apparently the image 
 delivery method objected to the additional whitespace.
 
 Does anyone have more examples of where scripts will fail IF they end with 
 ?  (note the additional space)?
 
 Cheers,
 
 tedd

I believe this can also be problematic if script A ends with ?  (with 
additional space) and script B includes script A at the top, which will cause 
the headers to be sent.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] To ? or not to ?

2012-04-03 Thread Robert Cummings


On 12-04-03 05:29 PM, Tedd Sperling wrote:

Hi gang:

Let me start a religious war -- should one end their scripts with ? or not?

After years of never having a problem with ending any of my scripts with ?, I 
found that several students in my class had scripts that did not produce the desired result even 
after they were given the scripts via highlight_file() to cut and paste.

As it turned out, several students copy/pasted the script with an addition whitespace after 
the ending ? and as such the scripts did not run as expected. You see, the 
scripts created image but apparently the image delivery method objected to the additional 
whitespace.

Does anyone have more examples of where scripts will fail IF they end with ?  
 (note the additional space)?


It's standard practice to NOT include the closing ? on anything 
remotely resembling a class or lib source file. As has been mentioned on 
this list and originally on PHP internals on several occasions, the 
optionality of the closing tag is intentional :)


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] To ? or not to ?

2012-04-03 Thread Joshua Kehn
I leave them off of any non-view PHP file. It doesn't have any downsides, and 
leaving them in can cause problems. Just like short tags! 

Regards,

–Josh

Joshua Kehn | @joshkehn 
http://joshuakehn.com

On Apr 3, 2012, at 5:29 PM, Tedd Sperling wrote:

 Hi gang:
 
 Let me start a religious war -- should one end their scripts with ? or not?
 
 After years of never having a problem with ending any of my scripts with 
 ?, I found that several students in my class had scripts that did not 
 produce the desired result even after they were given the scripts via 
 highlight_file() to cut and paste.
 
 As it turned out, several students copy/pasted the script with an addition 
 whitespace after the ending ? and as such the scripts did not run as 
 expected. You see, the scripts created image but apparently the image 
 delivery method objected to the additional whitespace.
 
 Does anyone have more examples of where scripts will fail IF they end with 
 ?  (note the additional space)?
 
 Cheers,
 
 tedd
 
 _
 tedd.sperl...@gmail.com
 http://sperling.com
 
 
 
 
 
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 



[PHP] Re: To ? or not to ?

2012-04-03 Thread Ross McKay
On Tue, 3 Apr 2012 17:29:33 -0400, Tedd Sperling wrote:

[...]
Does anyone have more examples of where scripts will fail 
IF they end with ?  (note the additional space)?

+1 on everyone's call to omit on an included file due to the potential
for sending headers.

[... rearranged for ease of reply ...]
You see, the scripts created image but apparently the image 
delivery method objected to the additional whitespace.

If you're sending binary data, you're best throwing in an exit() after
the last output. It doesn't matter then whether or not you have a
closing ?, with or without additional white space.
-- 
Ross McKay, Toronto, NSW Australia
The chief cause of problems is solutions -Eric Sevareid

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



[PHP] learning resources for PHP

2012-04-03 Thread Tim Dunphy
Hello list,

 I am quite sure that you've heard this question at least a few times
before. :) But I have been dabbling a bit in PHP for years and I've
decided that its' high time that became serious about getting a solid
grounding in it. Currently I work as a Sysadmin and have modest but
reliable skills in bash and perl. But I consider PHP more of an
artform and I really need to 'pick up a brush and start painting' so
to speak.

 So what I was wondering what websites, and books you'd recommend to
someone who (for all intents and purpose) is just starting out.

 On my hit list of things to learn are basic php / database
interaction (mysql mainly).. then how to accelerate php interraction
through memcache.. and eventually one I have all that down onto using
some of the NoSQLs (mongo/cassandra/membase, etc).

Thanks!

-- 
GPG me!!

gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B

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



Re: [PHP] To ? or not to ?

2012-04-03 Thread Donovan Brooke

Stuart Dallas wrote:
[snip]

Usually when setting headers after such a script has been included when output 
buffering is turned off. Personally I never put the closing ?  in if it's at 
the end of the file because it's unnecessary and can cause issues if it's present, 
but it's personal preference more than anything else.

Ultimately you have to consider that there's a reason it's optional - things like that 
don't generally happen by accident. I remember Rasmus commenting on this style issue a 
few years back so a search of the archives should find an official position.

-Stuart



Could using ob_start and ob_end_flush eliminate the ambiguity of whether 
or not to use '?'?


Donovan




--
D Brooke

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



Re: [PHP] To ? or not to ?

2012-04-03 Thread Robert Cummings

On 12-04-03 11:39 PM, Donovan Brooke wrote:

Stuart Dallas wrote:
[snip]

Usually when setting headers after such a script has been included when output 
buffering is turned off. Personally I never put the closing ?   in if it's at 
the end of the file because it's unnecessary and can cause issues if it's present, 
but it's personal preference more than anything else.

Ultimately you have to consider that there's a reason it's optional - things like that 
don't generally happen by accident. I remember Rasmus commenting on this style issue a 
few years back so a search of the archives should find an official position.

-Stuart



Could using ob_start and ob_end_flush eliminate the ambiguity of whether
or not to use '?'?


In the generally recommended case of don't use them at the end of your 
file... where's the ambiguity?


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] To ? or not to ?

2012-04-03 Thread Donovan Brooke

Robert Cummings wrote:
[snip]

Could using ob_start and ob_end_flush eliminate the ambiguity of whether
or not to use '?'?


In the generally recommended case of don't use them at the end of your
file... where's the ambiguity?



http://www.php.net/manual/en/function.include.php

http://www.php.net/manual/en/language.basic-syntax.phpmode.php

Those seem to suggest to use them... thus the ambiguity.


Donovan





--
D Brooke

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



Re: [PHP] To ? or not to ?

2012-04-03 Thread shiplu
I keep my closing tag. Earlier I started removing closing tag. Then I
search for the standardness of this practice and found its not standard.
Some frameworks/cms intentionally do this. Besides a signle `\n` character
is allowed after the closing tag which does not cause Can not send Header
error.  So I started using closing tag again.  Later I found, from visual
aspect, a closing tag makes the code balanced.
Still using it.
-- 
Shiplu.Mokadd.im
ImgSign.com | A dynamic signature machine
Innovation distinguishes between follower and leader


[PHP] RSS Standardness

2012-04-03 Thread shiplu
Dealing RSS Version.

I am going to write an RSS parser. Its a very simple parser which just
grabs the latest items date and title. SimpleXML and DomDocument is my
friend here. The problem here is there are too many standards for RSS. RSS
2.0, 0.92 and 0.91. What do you think which version should I implement? if
its not a single version then which versions?  I am also aware about
SimplePie which I have been using a lot. Here my preference is not to load
a library like SimplePie to just grab the title and date. I just want to
use DomDocument and SimpleXML.


Content-Type header.

RSS were called RDF prior to 0.91 and currently RDF is a different
protocol. How do you detect if the content is RSS 0.90 or Modern RDF if
content-type header is 'Application/rdf+xml'. Other content type with same
meaning is 'Application/rdf' and 'text/rdf'.

-- 
Shiplu.Mokadd.im
ImgSign.com | A dynamic signature machine
Innovation distinguishes between follower and leader