[PHP] How to write specification
Hi, I've been programing for some time, but I never tried to write code for two different application in same way. How when I work with more programmers it's even worse. Everyone is forcing it's way of writing functions inside classes or writing variables, etc. My idea is to code according to the standard protocol so that in future it would be easier to make applications. Is there some specification (or standard) how to write code for web application, but which describes all possibilities(writing css, JS, php, etc.)? Thanks in advance, Dusan -- made by ndusan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to write specification
2010/1/8 Dušan Novaković ndu...@gmail.com: I've been programing for some time, but I never tried to write code for two different application in same way. How when I work with more programmers it's even worse. Everyone is forcing it's way of writing functions inside classes or writing variables, etc. My idea is to code according to the standard protocol so that in future it would be easier to make applications. Is there some specification (or standard) how to write code for web application, but which describes all possibilities(writing css, JS, php, etc.)? Specification and coding standard are two different things... I think you're looking for a coding standard. Some helpful links: http://framework.zend.com/manual/en/coding-standard.html http://pear.php.net/manual/en/standards.php http://drupal.org/coding-standards http://www.dagbladet.no/development/phpcodingstandard/ [last updated 2003 - obsolete?] Pick one (at random if necessary) and don't make any changes. Changes imply discussion, and discussion is a waste of time. You can enforce a coding standard, should you so wish, at repository level: http://pear.php.net/manual/en/package.php.php-codesniffer.intro.php http://svnbook.red-bean.com/nightly/en/svn.reposadmin.create.html#svn.reposadmin.create.hooks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PHP programming strategy; lots of little include files, or a few big ones?
On Fri, Jan 8, 2010 at 3:48 AM, Robert Cummings rob...@interjinn.com wrote: They almost always make your shit run faster. I love your final statement Robert! A reply of good grammar and vocabulary summarised most succinctly. -- Graham -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] trying to launch kate from the browser....
I'm working on a better var_dump (http://mediabeez.ws/htmlMicroscope/, LGPL), and want to launch my kate editor when i click in the browser on a line in my trace-log. I'm trying to exec() this line, but it returns 1 (which is i believe a general error) echo hhh | sudo -u rene -S /bin/sh -c export HOME=/home/rene/ kate -l 21 -u /media/500gb/data2/www/htdocs/naaah/maintenance/maintenanceLogic.php if i open a terminal, do sudo su www-data and then execute the line above, then kate actually jumps to the right file, or opens it, etc. but from the browser, it won't work. exec($str,$o,$r); $r===1. i could use some help here..
[PHP] Re: trying to launch kate from the browser....
r...@ekster:~$ uname -a Linux ekster 2.6.31-17-generic #54-Ubuntu SMP Thu Dec 10 16:20:31 UTC 2009 i686 GNU/Linux r...@ekster:~$ apache2 -v Server version: Apache/2.2.12 (Ubuntu) Server built: Nov 12 2009 22:49:46 r...@ekster:~$ php -v PHP 5.2.10-2ubuntu6.3 with Suhosin-Patch 0.9.7 (cli) (built: Nov 26 2009 14:42:49) Copyright (c) 1997-2009 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies r...@ekster:~$ kate -v Qt: 4.5.2 KDE: 4.3.2 (KDE 4.3.2) Kate: 3.3.2
Re: [PHP] trying to launch kate from the browser....
On Fri, 2010-01-08 at 13:41 +0100, Rene Veerman wrote: I'm working on a better var_dump (http://mediabeez.ws/htmlMicroscope/, LGPL), and want to launch my kate editor when i click in the browser on a line in my trace-log. I'm trying to exec() this line, but it returns 1 (which is i believe a general error) echo hhh | sudo -u rene -S /bin/sh -c export HOME=/home/rene/ kate -l 21 -u /media/500gb/data2/www/htdocs/naaah/maintenance/maintenanceLogic.php if i open a terminal, do sudo su www-data and then execute the line above, then kate actually jumps to the right file, or opens it, etc. but from the browser, it won't work. exec($str,$o,$r); $r===1. i could use some help here.. If you click a link in the browser, you can't get it to open up programs for you on your local machine. The work is done under the user of the web server, so you won't see Kate open up at all. Kate supports all the kio slaves, so there may be a protocal you can stream the content down to kate, and have the link point to the file via this protocol. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] trying to launch kate from the browser....
Thanks for the reply.. I only need this to work locally on the web-server for now.. So i'm calling a script through ajax routines, which would do the exec(). Since it's on the local webserver, that should work, right?
Re: [PHP] trying to launch kate from the browser....
On Fri, 2010-01-08 at 13:48 +0100, Rene Veerman wrote: Thanks for the reply.. I only need this to work locally on the web-server for now.. So i'm calling a script through ajax routines, which would do the exec(). Since it's on the local webserver, that should work, right? No, the server is very different from the client, even if they are on the same machine. I know of no way you can have an HTML link open up software on your machine. If it were possible, that would open up a whole world of security issues. What about making the link something like ftp://localhost/somefile and have an FTP server set up on the same machine. You could set up your local machine to respond as you wish to the ftp:// link (might be easier to configure in Konqueror) Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] trying to launch kate from the browser....
On 8 Jan 2010, at 12:48, Rene Veerman wrote: Thanks for the reply.. I only need this to work locally on the web-server for now.. So i'm calling a script through ajax routines, which would do the exec(). Since it's on the local webserver, that should work, right? No. When the web server runs a PHP script it has no access to the terminal of the logged in user. What you are trying to do is certainly possible but won't be easy. An easier way to do it would be to write an app and register a URL scheme to open with that app (whatever://localhost/filename). That app can then do whatever you need it to with the URL which it will get passed as an argument. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Fwd: [PHP] trying to launch kate from the browser....
-- Forwarded message -- From: Rene Veerman rene7...@gmail.com Date: Fri, Jan 8, 2010 at 1:58 PM Subject: Re: [PHP] trying to launch kate from the browser To: a...@ashleysheridan.co.uk Yep, i also just thought of using ssh/ftp to remotely edit files. I can probably configure any web-browser to open certain links with any local program. But for now, i'd just like to consider the case where the browser is on the same machine as the webserver. In that case, you should (imo) be able to use exec() called with ajax from the browser to startup apps on that machine. On Fri, Jan 8, 2010 at 1:49 PM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: No, the server is very different from the client, even if they are on the same machine. I know of no way you can have an HTML link open up software on your machine. If it were possible, that would open up a whole world of security issues. What about making the link something like ftp://localhost/somefile and have an FTP server set up on the same machine. You could set up your local machine to respond as you wish to the ftp:// link (might be easier to configure in Konqueror) Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] trying to launch kate from the browser....
oh, echo blah | sudo -u rene -S /bin/sh -c export HOME=/home/rene/ exec($str,$o,$r); $r === 0. so that works. therefore, it must be kate itself that refuses to start up from apache's context. too bad $o === empty array. any ideas are most welcome.
RE: [PHP] trying to launch kate from the browser....
From: Rene Veerman From: Rene Veerman rene7...@gmail.com Yep, i also just thought of using ssh/ftp to remotely edit files. I can probably configure any web-browser to open certain links with any local program. But for now, i'd just like to consider the case where the browser is on the same machine as the webserver. In that case, you should (imo) be able to use exec() called with ajax from the browser to startup apps on that machine. On Fri, Jan 8, 2010 at 1:49 PM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: No, the server is very different from the client, even if they are on the same machine. I know of no way you can have an HTML link open up software on your machine. If it were possible, that would open up a whole world of security issues. What about making the link something like ftp://localhost/somefile and have an FTP server set up on the same machine. You could set up your local machine to respond as you wish to the ftp:// link (might be easier to configure in Konqueror) You might be able to set kate as a helper app in the browser, but you still have two problems. A. How do you map the file path from the web server's docroot to the real path? i.e. can you translate the URL into a real file path? B. Does the browser user have access rights to that file/directory? It's probably easier to set up NetBeans with the debugger. That combination is designed to do what you are asking for. Bob McConnell -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] trying to launch kate from the browser....
$str = ''echo blah | sudo -u rene -S /bin/sh -c export HOME=/home/rene/ export''; exec($str,$o,$r); $r === 0. $o = pre class='xdebug-var-dump' dir='ltr' barray/b 0 = 'export HOME=apos;/home/rene/apos;' .more. /pre
Fwd: [PHP] trying to launch kate from the browser....
-- Forwarded message -- From: Rene Veerman rene7...@gmail.com Date: Fri, Jan 8, 2010 at 2:29 PM Subject: Re: [PHP] trying to launch kate from the browser To: Bob McConnell r...@cbord.com A: str_replace() ;) maybe a preg_replace() but i dont think thats even necessary. B: the sudo (see my last mails) is successfull, and i can update the environment too. so it executes as user rene on the webserver. the webbrowser just tells the server which of it's own files to kick to the kate editor. On Fri, Jan 8, 2010 at 2:23 PM, Bob McConnell r...@cbord.com wrote: You might be able to set kate as a helper app in the browser, but you still have two problems. A. How do you map the file path from the web server's docroot to the real path? i.e. can you translate the URL into a real file path? B. Does the browser user have access rights to that file/directory? It's probably easier to set up NetBeans with the debugger. That combination is designed to do what you are asking for.
Re: [PHP] trying to launch kate from the browser....
hmm. after a nap i'm gonna try to start the editor directly from the browser instead, with ssh:// hopefully to get/write the file on the server.
Re: [PHP] Re: PHP programming strategy; lots of little include files, or a few big ones?
On Thu, Jan 7, 2010 at 10:48 PM, Robert Cummings rob...@interjinn.com wrote: ... They almost always make your shit run faster. You know they make medicine for that? ;-) Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] trying to launch kate from the browser....
Op 1/8/10 1:41 PM, Rene Veerman schreef: I'm working on a better var_dump (http://mediabeez.ws/htmlMicroscope/, LGPL), and want to launch my kate editor when i click in the browser on a line in my trace-log. I'm trying to exec() this line, but it returns 1 (which is i believe a general error) echo hhh | sudo -u rene -S /bin/sh -c export HOME=/home/rene/ kate -l 21 -u /media/500gb/data2/www/htdocs/naaah/maintenance/maintenanceLogic.php if i open a terminal, do sudo su www-data and then execute the line above, then kate actually jumps to the right file, or opens it, etc. but from the browser, it won't work. exec($str,$o,$r); $r===1. i could use some help here.. seems everyone has the wrong idea about what your trying to do. it is possible, given that your webserver and your browser are running on the machine - if the webserver manages to start Kate up then you'll see the editor on your screen. the only problem you *seem* to have is the fact that your webserver doesn't have the ness. permissions to run the exec command (I'd guess it's specifically related to the fact that the user apache runs as doesn't have the perms to run sudo, at least not in the context of your user account) ... try fudging your sudoers file to give the user your apache instance runs as the perms to run 'sudo kate' as you ... then restart apache (just in case) and see what happens. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PHP programming strategy; lots of little include files, or a few big ones?
Graham Cossey wrote: On Fri, Jan 8, 2010 at 3:48 AM, Robert Cummings rob...@interjinn.com wrote: They almost always make your shit run faster. I love your final statement Robert! A reply of good grammar and vocabulary summarised most succinctly. :) -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PHP programming strategy; lots of little include files, or a few big ones?
clanc...@cybec.com.au wrote: On Thu, 07 Jan 2010 22:48:59 -0500, rob...@interjinn.com (Robert Cummings) wrote: clanc...@cybec.com.au wrote: Thank you all for your comments. I did not know about bytecode caches. They're an interesting concept, but if I am interpreting the paper http://itst.net/654-php-on-fire-three-opcode-caches-compared correctly they only double the average speed of operation, which is rather less than I would have anticipated. I strongly advise that you take the time to try a bytecode cache. Within linux environments I am partial to eaccelerator. In IIS environments I now use WinCache from Microsoft. From my own observations with a multitude of different types of PHP web applications I find that the speed gain is closer to 5 times faster on average. Five times faster is certainly more attractive than twice as fast. But under what circumstances is this achieved? Unfortunately these days it is difficult to find any solid information on how things actually work, but my impression is that caches only work for pages which are frequently accessed. If this is correct, and (as I suspect) somebody looks at my website once an hour, the page will not be in the cache, so it won't help. Also one of the more popular parts of this website is my photo album, and for this much of the access time will be the download time of the photos. Furthermore as each visitor will look at a different set of photos, even with heavy access it is unlikely that any given photo would be in a cache. A particular cache of bytecode is usually pushed out of memory when the configured maximum amount of memory for the bytecode cache is about to be exceeded. Additionally, the particular cache that gets eliminated is usually the oldest or least used cache. Given this, and your purported usage patterns, your pages will most likely remain in the cache until such time as you update the code or restart the webserver. Despite these comments the access times for my websites seem to be pretty good -- certainly a lot better than many commercial websites -- but have a look at http://www.corybas.com/, and see what you think. (I am in the process of updating this, and know that the technical notes are not currently working, but there is plenty there to show you what I'm trying to do.) I'm not disputing your good enough statistics. I'm merely asserting that a bytecode cache will resolve your concerns about file access times when your code is strewn across many compartmentalized files. In addition, I am advising that it is good practice to always install a bytecode cache. One of the first things I do when setting up a new system is to ensure I put an accelerator in place. Once it's in place, no matter how many pages or sub sites I put up, the accelerator is already in place and providing benefits. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PHP programming strategy; lots of little include files, or a few big ones?
Hi, A note on bytecode caching and include/include_once performance. A while ago when we were profiling our code, we did notice that file includes do take a noticeable percentage of overall overhead (enough for us to look into it more deep). We are using apc cache on a standard LAMP platform (linux 2.6 series, apache 2.2x and PHP 5 series). Our includes were using 'relative' paths (e.g. include_once '../common/somefile.inc' or include_once 'lib/somefuncs.inc' ) and within APC cache logic, it resolves such relative paths to absolute paths via a realpath() calls. This can be fairly file-system intensive (lots of syscalls like stat() and readlink() to resolve symlinks etc...). APC uses absolute paths as key into the opcode cache. This gets worse if it has to find your files via the 'ini_path' setting (and most of your library or common code is not in the first component or so ). So from APC cache perspective, it is most efficient if your include paths are all absolute (realpath() logic is skipped) - e.g.: include_once $BASE_DIR . '/common/somefile.inc'; include_once $BASE_DIR . '/lib/somefuncs.inc'; and so on where '$BASE_DIR' could be set via apache Setenv directives ( $_SERVER['BASE_DIR'] or even hardcoded all over the place). There were other issues with include vs include_once and apc cache, but I don't recall why there were performance difference (with include only even with relative paths, the performance was better, but managing dependencies is to cumbersome). Not sure how other bytecode cache handles relative paths but I suspect it has to do something similar. From a pure code readability point of view and more automated dependency management (as close to compiled languages as possible), I do favor include_once/require_once strategy with absolute path strategy, but it is not unheard of where to squeeze out maximal performance, a giant single 'include' is done. Sometimes this is done on prod. systems where a parser goes through and generates this big include file, and ensure it is placed somewhere in the beginning the main 'controller.php' (MVC model) and all other includes stripped off. Hope this helps in making your decision. Ravi On Fri, Jan 8, 2010 at 8:59 AM, Robert Cummings rob...@interjinn.com wrote: clanc...@cybec.com.au wrote: On Thu, 07 Jan 2010 22:48:59 -0500, rob...@interjinn.com (Robert Cummings) wrote: clanc...@cybec.com.au wrote: Thank you all for your comments. I did not know about bytecode caches. They're an interesting concept, but if I am interpreting the paper http://itst.net/654-php-on-fire-three-opcode-caches-compared correctly they only double the average speed of operation, which is rather less than I would have anticipated. I strongly advise that you take the time to try a bytecode cache. Within linux environments I am partial to eaccelerator. In IIS environments I now use WinCache from Microsoft. From my own observations with a multitude of different types of PHP web applications I find that the speed gain is closer to 5 times faster on average. Five times faster is certainly more attractive than twice as fast. But under what circumstances is this achieved? Unfortunately these days it is difficult to find any solid information on how things actually work, but my impression is that caches only work for pages which are frequently accessed. If this is correct, and (as I suspect) somebody looks at my website once an hour, the page will not be in the cache, so it won't help. Also one of the more popular parts of this website is my photo album, and for this much of the access time will be the download time of the photos. Furthermore as each visitor will look at a different set of photos, even with heavy access it is unlikely that any given photo would be in a cache. A particular cache of bytecode is usually pushed out of memory when the configured maximum amount of memory for the bytecode cache is about to be exceeded. Additionally, the particular cache that gets eliminated is usually the oldest or least used cache. Given this, and your purported usage patterns, your pages will most likely remain in the cache until such time as you update the code or restart the webserver. Despite these comments the access times for my websites seem to be pretty good -- certainly a lot better than many commercial websites -- but have a look at http://www.corybas.com/, and see what you think. (I am in the process of updating this, and know that the technical notes are not currently working, but there is plenty there to show you what I'm trying to do.) I'm not disputing your good enough statistics. I'm merely asserting that a bytecode cache will resolve your concerns about file access times when your code is strewn across many compartmentalized files. In addition, I am advising that it is good practice to always install a bytecode cache. One of the first things I do when setting up a new system is to ensure I put an
Re: [PHP] Re: PHP programming strategy; lots of little include files, or a few big ones?
Sorry forgot to mention that we used APC with apc.stat turned off which will give a little bit more performance gain, but it does mean flushing the cache on every code push (which is trivial). Ravi On Fri, Jan 8, 2010 at 11:30 AM, J Ravi Menon jravime...@gmail.com wrote: Hi, A note on bytecode caching and include/include_once performance. A while ago when we were profiling our code, we did notice that file includes do take a noticeable percentage of overall overhead (enough for us to look into it more deep). We are using apc cache on a standard LAMP platform (linux 2.6 series, apache 2.2x and PHP 5 series). Our includes were using 'relative' paths (e.g. include_once '../common/somefile.inc' or include_once 'lib/somefuncs.inc' ) and within APC cache logic, it resolves such relative paths to absolute paths via a realpath() calls. This can be fairly file-system intensive (lots of syscalls like stat() and readlink() to resolve symlinks etc...). APC uses absolute paths as key into the opcode cache. This gets worse if it has to find your files via the 'ini_path' setting (and most of your library or common code is not in the first component or so ). So from APC cache perspective, it is most efficient if your include paths are all absolute (realpath() logic is skipped) - e.g.: include_once $BASE_DIR . '/common/somefile.inc'; include_once $BASE_DIR . '/lib/somefuncs.inc'; and so on where '$BASE_DIR' could be set via apache Setenv directives ( $_SERVER['BASE_DIR'] or even hardcoded all over the place). There were other issues with include vs include_once and apc cache, but I don't recall why there were performance difference (with include only even with relative paths, the performance was better, but managing dependencies is to cumbersome). Not sure how other bytecode cache handles relative paths but I suspect it has to do something similar. From a pure code readability point of view and more automated dependency management (as close to compiled languages as possible), I do favor include_once/require_once strategy with absolute path strategy, but it is not unheard of where to squeeze out maximal performance, a giant single 'include' is done. Sometimes this is done on prod. systems where a parser goes through and generates this big include file, and ensure it is placed somewhere in the beginning the main 'controller.php' (MVC model) and all other includes stripped off. Hope this helps in making your decision. Ravi On Fri, Jan 8, 2010 at 8:59 AM, Robert Cummings rob...@interjinn.com wrote: clanc...@cybec.com.au wrote: On Thu, 07 Jan 2010 22:48:59 -0500, rob...@interjinn.com (Robert Cummings) wrote: clanc...@cybec.com.au wrote: Thank you all for your comments. I did not know about bytecode caches. They're an interesting concept, but if I am interpreting the paper http://itst.net/654-php-on-fire-three-opcode-caches-compared correctly they only double the average speed of operation, which is rather less than I would have anticipated. I strongly advise that you take the time to try a bytecode cache. Within linux environments I am partial to eaccelerator. In IIS environments I now use WinCache from Microsoft. From my own observations with a multitude of different types of PHP web applications I find that the speed gain is closer to 5 times faster on average. Five times faster is certainly more attractive than twice as fast. But under what circumstances is this achieved? Unfortunately these days it is difficult to find any solid information on how things actually work, but my impression is that caches only work for pages which are frequently accessed. If this is correct, and (as I suspect) somebody looks at my website once an hour, the page will not be in the cache, so it won't help. Also one of the more popular parts of this website is my photo album, and for this much of the access time will be the download time of the photos. Furthermore as each visitor will look at a different set of photos, even with heavy access it is unlikely that any given photo would be in a cache. A particular cache of bytecode is usually pushed out of memory when the configured maximum amount of memory for the bytecode cache is about to be exceeded. Additionally, the particular cache that gets eliminated is usually the oldest or least used cache. Given this, and your purported usage patterns, your pages will most likely remain in the cache until such time as you update the code or restart the webserver. Despite these comments the access times for my websites seem to be pretty good -- certainly a lot better than many commercial websites -- but have a look at http://www.corybas.com/, and see what you think. (I am in the process of updating this, and know that the technical notes are not currently working, but there is plenty there to show you what I'm trying to do.) I'm not disputing your good enough statistics. I'm merely asserting
[PHP] POLL: To add the final ? or not...
I'm having a debate with a co-worker about adding the final ? on a PHP page... To be honest, I am the lead, and I could pull rank and be done with the discussion, however I don't like to be that way. I would rather do the right thing. If my way of thinking is old-school (I've been coding since PHP/FI), and what he says is the newfangled proper PHP/Zend way, then I'd rather adopt that, despite how icky it makes me feel to leave an unclosed ?php just dangling and alone, all sad-like. In my mind, nobody gets left behind! :) Is there ANY side-effects to leaving the end ? off? Is it any more work for the compiler? And yes I know computers are hella-fast and all that, but I come from the gaming industry where squeeking out an extra FPS matters, and shaving off 0.01s per row of data in a table matters if you have more than 100 rows. A 1 second wait IS noticeable and a 10 second is even moreso -- just try to talk for 10 seconds straight without a pause. Or sit there and stare at a screen for 10 seconds! If the main argument is that it's to prevent white-space after the code, then most modern editors that I'm aware of will automatically trim white-space (or have a setting to do so). Plus this is ONLY a factor when you're trying to output a header and things like that. In 90% of your code, you don't deal with that. It's also obvious enough when you have an extra character/space because PHP pukes on the screen and TELLS you something about blah blah sent before header output or something to that effect. What do you guys all do? I also created a poll here http://www.rapidpoll.net/arc1opy -Original Message- From: Co-worker To: Daevid Vincent Actually, Zend states that you should omit the final ? on include pages. There is no harm in the action, and it prevents you from accidentally adding white space after the tag which will break the code. http://framework.zend.com/manual/en/coding-standard.php-file-formatting.htm l -Original Message- From: Daevid Vincent To: Co-worker Please DO include the final ? I noticed on several of your files that you have purposely omitted it. Yes, I know the files work without them, but it makes things easier to see the pairings for matching ?php . Plus it keeps things consistent and I'm not a big fan of special cases as this is, especially if it's a bad habit to get into since in all other cases it's required except this one lazy one. If you are concerned about white space sending in a header or something, well then just make sure there isn't any. I've had no problems and it makes you a more careful coder. Thanks, Daevid. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POLL: To add the final ? or not...
On Fri, 2010-01-08 at 12:24 -0800, Daevid Vincent wrote: I'm having a debate with a co-worker about adding the final ? on a PHP page... To be honest, I am the lead, and I could pull rank and be done with the discussion, however I don't like to be that way. I would rather do the right thing. If my way of thinking is old-school (I've been coding since PHP/FI), and what he says is the newfangled proper PHP/Zend way, then I'd rather adopt that, despite how icky it makes me feel to leave an unclosed ?php just dangling and alone, all sad-like. In my mind, nobody gets left behind! :) Is there ANY side-effects to leaving the end ? off? Is it any more work for the compiler? And yes I know computers are hella-fast and all that, but I come from the gaming industry where squeeking out an extra FPS matters, and shaving off 0.01s per row of data in a table matters if you have more than 100 rows. A 1 second wait IS noticeable and a 10 second is even moreso -- just try to talk for 10 seconds straight without a pause. Or sit there and stare at a screen for 10 seconds! If the main argument is that it's to prevent white-space after the code, then most modern editors that I'm aware of will automatically trim white-space (or have a setting to do so). Plus this is ONLY a factor when you're trying to output a header and things like that. In 90% of your code, you don't deal with that. It's also obvious enough when you have an extra character/space because PHP pukes on the screen and TELLS you something about blah blah sent before header output or something to that effect. What do you guys all do? I also created a poll here http://www.rapidpoll.net/arc1opy -Original Message- From: Co-worker To: Daevid Vincent Actually, Zend states that you should omit the final ? on include pages. There is no harm in the action, and it prevents you from accidentally adding white space after the tag which will break the code. http://framework.zend.com/manual/en/coding-standard.php-file-formatting.htm l -Original Message- From: Daevid Vincent To: Co-worker Please DO include the final ? I noticed on several of your files that you have purposely omitted it. Yes, I know the files work without them, but it makes things easier to see the pairings for matching ?php . Plus it keeps things consistent and I'm not a big fan of special cases as this is, especially if it's a bad habit to get into since in all other cases it's required except this one lazy one. If you are concerned about white space sending in a header or something, well then just make sure there isn't any. I've had no problems and it makes you a more careful coder. Thanks, Daevid. I always include the final ? for neatness, and have had no problems doing so. There is an argument that leaving off the ? prevents multibyte end of line markers from causing problems with headers being sent when the PHP file is being included in another, but I've not had this problem on the text editors I use. That said, some systems do have coding style conventions regarding them, so if your code is to be included in any of those, then maybe it's best following their conventions. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] POLL: To add the final ? or not...
http://framework.zend.com/manual/en/coding-standard.html#coding-standard.overview.scope This document provides guidelines for code formatting and documentation to individuals and teams contributing to Zend Framework. So as far as anything other than code being contributed to Zend Framework, its just a suggestion. For your programming team, you're the boss, you make the decision. The only benefit I see is preventing the white space mistake (as your co-worker's quote mentioned), but I agree with you on that point. Just don't put any white space there... moron... :-) Its an inconsequential option, pull rank, get back to work. On Fri, Jan 8, 2010 at 1:24 PM, Daevid Vincent dae...@daevid.com wrote: I'm having a debate with a co-worker about adding the final ? on a PHP page... To be honest, I am the lead, and I could pull rank and be done with the discussion, however I don't like to be that way. I would rather do the right thing. If my way of thinking is old-school (I've been coding since PHP/FI), and what he says is the newfangled proper PHP/Zend way, then I'd rather adopt that, despite how icky it makes me feel to leave an unclosed ?php just dangling and alone, all sad-like. In my mind, nobody gets left behind! :) Is there ANY side-effects to leaving the end ? off? Is it any more work for the compiler? And yes I know computers are hella-fast and all that, but I come from the gaming industry where squeeking out an extra FPS matters, and shaving off 0.01s per row of data in a table matters if you have more than 100 rows. A 1 second wait IS noticeable and a 10 second is even moreso -- just try to talk for 10 seconds straight without a pause. Or sit there and stare at a screen for 10 seconds! If the main argument is that it's to prevent white-space after the code, then most modern editors that I'm aware of will automatically trim white-space (or have a setting to do so). Plus this is ONLY a factor when you're trying to output a header and things like that. In 90% of your code, you don't deal with that. It's also obvious enough when you have an extra character/space because PHP pukes on the screen and TELLS you something about blah blah sent before header output or something to that effect. What do you guys all do? I also created a poll here http://www.rapidpoll.net/arc1opy -Original Message- From: Co-worker To: Daevid Vincent Actually, Zend states that you should omit the final ? on include pages. There is no harm in the action, and it prevents you from accidentally adding white space after the tag which will break the code. http://framework.zend.com/manual/en/coding-standard.php-file-formatting.htm l -Original Message- From: Daevid Vincent To: Co-worker Please DO include the final ? I noticed on several of your files that you have purposely omitted it. Yes, I know the files work without them, but it makes things easier to see the pairings for matching ?php . Plus it keeps things consistent and I'm not a big fan of special cases as this is, especially if it's a bad habit to get into since in all other cases it's required except this one lazy one. If you are concerned about white space sending in a header or something, well then just make sure there isn't any. I've had no problems and it makes you a more careful coder. Thanks, Daevid. -- 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] Re: PHP programming strategy; lots of little include files, or a few big ones?
On Jan 8, 2010, at 10:44 AM, Andrew Ballard aball...@gmail.com wrote: On Thu, Jan 7, 2010 at 10:48 PM, Robert Cummings rob...@interjinn.com wrote: ... They almost always make your shit run faster. You know they make medicine for that? ;-) Andrew -- Tacos? Bastien Sent from my iPod -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Question about using JSON_ENCODE()
I'm developing a basic webservice to compliment a mobile application I'm developing or iPhone. While I know how to encode simple variables and arrays, I'm not sure how to do what I'm needing to do. Basically, I want to encode a status message to return to the mobile client. Something like status good_request Right now, I'm thinking I should put this in an array and encode/return that. But is that the right way of thinking? Is there a more correct or better way to do this? Thanks! Anthony -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about using JSON_ENCODE()
Yup, you put result in an array $result = array('status' = 'good'); and return encoded string return Json_Encode($result); your client will get a string '{status: good}' and you use your client tech(eg. javascrpt) to decode this string and finall get an object On Fri, Jan 8, 2010 at 3:43 PM, Anthony Papillion papill...@gmail.comwrote: I'm developing a basic webservice to compliment a mobile application I'm developing or iPhone. While I know how to encode simple variables and arrays, I'm not sure how to do what I'm needing to do. Basically, I want to encode a status message to return to the mobile client. Something like status good_request Right now, I'm thinking I should put this in an array and encode/return that. But is that the right way of thinking? Is there a more correct or better way to do this? Thanks! Anthony -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POLL: To add the final ? or not...
if you use the newest PDT, you will find that a new php file has no final ? I vote for your co-worker [?] On Fri, Jan 8, 2010 at 3:49 PM, LinuxManMikeC linuxmanmi...@gmail.comwrote: http://framework.zend.com/manual/en/coding-standard.html#coding-standard.overview.scope This document provides guidelines for code formatting and documentation to individuals and teams contributing to Zend Framework. So as far as anything other than code being contributed to Zend Framework, its just a suggestion. For your programming team, you're the boss, you make the decision. The only benefit I see is preventing the white space mistake (as your co-worker's quote mentioned), but I agree with you on that point. Just don't put any white space there... moron... :-) Its an inconsequential option, pull rank, get back to work. On Fri, Jan 8, 2010 at 1:24 PM, Daevid Vincent dae...@daevid.com wrote: I'm having a debate with a co-worker about adding the final ? on a PHP page... To be honest, I am the lead, and I could pull rank and be done with the discussion, however I don't like to be that way. I would rather do the right thing. If my way of thinking is old-school (I've been coding since PHP/FI), and what he says is the newfangled proper PHP/Zend way, then I'd rather adopt that, despite how icky it makes me feel to leave an unclosed ?php just dangling and alone, all sad-like. In my mind, nobody gets left behind! :) Is there ANY side-effects to leaving the end ? off? Is it any more work for the compiler? And yes I know computers are hella-fast and all that, but I come from the gaming industry where squeeking out an extra FPS matters, and shaving off 0.01s per row of data in a table matters if you have more than 100 rows. A 1 second wait IS noticeable and a 10 second is even moreso -- just try to talk for 10 seconds straight without a pause. Or sit there and stare at a screen for 10 seconds! If the main argument is that it's to prevent white-space after the code, then most modern editors that I'm aware of will automatically trim white-space (or have a setting to do so). Plus this is ONLY a factor when you're trying to output a header and things like that. In 90% of your code, you don't deal with that. It's also obvious enough when you have an extra character/space because PHP pukes on the screen and TELLS you something about blah blah sent before header output or something to that effect. What do you guys all do? I also created a poll here http://www.rapidpoll.net/arc1opy -Original Message- From: Co-worker To: Daevid Vincent Actually, Zend states that you should omit the final ? on include pages. There is no harm in the action, and it prevents you from accidentally adding white space after the tag which will break the code. http://framework.zend.com/manual/en/coding-standard.php-file-formatting.htm l -Original Message- From: Daevid Vincent To: Co-worker Please DO include the final ? I noticed on several of your files that you have purposely omitted it. Yes, I know the files work without them, but it makes things easier to see the pairings for matching ?php . Plus it keeps things consistent and I'm not a big fan of special cases as this is, especially if it's a bad habit to get into since in all other cases it's required except this one lazy one. If you are concerned about white space sending in a header or something, well then just make sure there isn't any. I've had no problems and it makes you a more careful coder. Thanks, Daevid. -- 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] POLL: To add the final ? or not...
On 8 Jan 2010, at 20:49, LinuxManMikeC wrote: http://framework.zend.com/manual/en/coding-standard.html#coding-standard.overview.scope This document provides guidelines for code formatting and documentation to individuals and teams contributing to Zend Framework. So as far as anything other than code being contributed to Zend Framework, its just a suggestion. For your programming team, you're the boss, you make the decision. The only benefit I see is preventing the white space mistake (as your co-worker's quote mentioned), but I agree with you on that point. Just don't put any white space there... moron... :-) Its an inconsequential option, pull rank, get back to work. My opinion is that it's not an inconsequential option. Putting it in can cause issues, leaving it out does nothing but rub against some people's sense of neatness and order. Given the choice I'll always vote for the one that doesn't cause issues - I'd rather have people a tiny bit uncomfortable with not having it there than finding out there's a bit of whitespace at the end of a file when it could be in one of thousands. But maybe that's just me. -Stuart -- http://stut.net/ On Fri, Jan 8, 2010 at 1:24 PM, Daevid Vincent dae...@daevid.com wrote: I'm having a debate with a co-worker about adding the final ? on a PHP page... To be honest, I am the lead, and I could pull rank and be done with the discussion, however I don't like to be that way. I would rather do the right thing. If my way of thinking is old-school (I've been coding since PHP/FI), and what he says is the newfangled proper PHP/Zend way, then I'd rather adopt that, despite how icky it makes me feel to leave an unclosed ?php just dangling and alone, all sad-like. In my mind, nobody gets left behind! :) Is there ANY side-effects to leaving the end ? off? Is it any more work for the compiler? And yes I know computers are hella-fast and all that, but I come from the gaming industry where squeeking out an extra FPS matters, and shaving off 0.01s per row of data in a table matters if you have more than 100 rows. A 1 second wait IS noticeable and a 10 second is even moreso -- just try to talk for 10 seconds straight without a pause. Or sit there and stare at a screen for 10 seconds! If the main argument is that it's to prevent white-space after the code, then most modern editors that I'm aware of will automatically trim white-space (or have a setting to do so). Plus this is ONLY a factor when you're trying to output a header and things like that. In 90% of your code, you don't deal with that. It's also obvious enough when you have an extra character/space because PHP pukes on the screen and TELLS you something about blah blah sent before header output or something to that effect. What do you guys all do? I also created a poll here http://www.rapidpoll.net/arc1opy -Original Message- From: Co-worker To: Daevid Vincent Actually, Zend states that you should omit the final ? on include pages. There is no harm in the action, and it prevents you from accidentally adding white space after the tag which will break the code. http://framework.zend.com/manual/en/coding-standard.php-file-formatting.htm l -Original Message- From: Daevid Vincent To: Co-worker Please DO include the final ? I noticed on several of your files that you have purposely omitted it. Yes, I know the files work without them, but it makes things easier to see the pairings for matching ?php . Plus it keeps things consistent and I'm not a big fan of special cases as this is, especially if it's a bad habit to get into since in all other cases it's required except this one lazy one. If you are concerned about white space sending in a header or something, well then just make sure there isn't any. I've had no problems and it makes you a more careful coder. Thanks, Daevid. -- 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POLL: To add the final ? or not...
On Fri, 2010-01-08 at 21:30 +, Stuart Dallas wrote: On 8 Jan 2010, at 20:49, LinuxManMikeC wrote: http://framework.zend.com/manual/en/coding-standard.html#coding-standard.overview.scope This document provides guidelines for code formatting and documentation to individuals and teams contributing to Zend Framework. So as far as anything other than code being contributed to Zend Framework, its just a suggestion. For your programming team, you're the boss, you make the decision. The only benefit I see is preventing the white space mistake (as your co-worker's quote mentioned), but I agree with you on that point. Just don't put any white space there... moron... :-) Its an inconsequential option, pull rank, get back to work. My opinion is that it's not an inconsequential option. Putting it in can cause issues, leaving it out does nothing but rub against some people's sense of neatness and order. Given the choice I'll always vote for the one that doesn't cause issues - I'd rather have people a tiny bit uncomfortable with not having it there than finding out there's a bit of whitespace at the end of a file when it could be in one of thousands. But maybe that's just me. -Stuart -- http://stut.net/ On Fri, Jan 8, 2010 at 1:24 PM, Daevid Vincent dae...@daevid.com wrote: I'm having a debate with a co-worker about adding the final ? on a PHP page... To be honest, I am the lead, and I could pull rank and be done with the discussion, however I don't like to be that way. I would rather do the right thing. If my way of thinking is old-school (I've been coding since PHP/FI), and what he says is the newfangled proper PHP/Zend way, then I'd rather adopt that, despite how icky it makes me feel to leave an unclosed ?php just dangling and alone, all sad-like. In my mind, nobody gets left behind! :) Is there ANY side-effects to leaving the end ? off? Is it any more work for the compiler? And yes I know computers are hella-fast and all that, but I come from the gaming industry where squeeking out an extra FPS matters, and shaving off 0.01s per row of data in a table matters if you have more than 100 rows. A 1 second wait IS noticeable and a 10 second is even moreso -- just try to talk for 10 seconds straight without a pause. Or sit there and stare at a screen for 10 seconds! If the main argument is that it's to prevent white-space after the code, then most modern editors that I'm aware of will automatically trim white-space (or have a setting to do so). Plus this is ONLY a factor when you're trying to output a header and things like that. In 90% of your code, you don't deal with that. It's also obvious enough when you have an extra character/space because PHP pukes on the screen and TELLS you something about blah blah sent before header output or something to that effect. What do you guys all do? I also created a poll here http://www.rapidpoll.net/arc1opy -Original Message- From: Co-worker To: Daevid Vincent Actually, Zend states that you should omit the final ? on include pages. There is no harm in the action, and it prevents you from accidentally adding white space after the tag which will break the code. http://framework.zend.com/manual/en/coding-standard.php-file-formatting.htm l -Original Message- From: Daevid Vincent To: Co-worker Please DO include the final ? I noticed on several of your files that you have purposely omitted it. Yes, I know the files work without them, but it makes things easier to see the pairings for matching ?php . Plus it keeps things consistent and I'm not a big fan of special cases as this is, especially if it's a bad habit to get into since in all other cases it's required except this one lazy one. If you are concerned about white space sending in a header or something, well then just make sure there isn't any. I've had no problems and it makes you a more careful coder. Thanks, Daevid. -- 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 If someone is leaving whitespace all over the place that's causing those sorts of problems, then their use of ? is the least of your problems, as I suspect their code layout is probably atrocious! Getting code laid out correctly is far more important an issue than a closing ?, and when it's done correctly, you avoid a lot of problems, more than a closing ? can cause. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] POLL: To add the final ? or not...
On 8 Jan 2010, at 21:38, Ashley Sheridan wrote: On Fri, 2010-01-08 at 21:30 +, Stuart Dallas wrote: On 8 Jan 2010, at 20:49, LinuxManMikeC wrote: http://framework.zend.com/manual/en/coding-standard.html#coding-standard.overview.scope This document provides guidelines for code formatting and documentation to individuals and teams contributing to Zend Framework. So as far as anything other than code being contributed to Zend Framework, its just a suggestion. For your programming team, you're the boss, you make the decision. The only benefit I see is preventing the white space mistake (as your co-worker's quote mentioned), but I agree with you on that point. Just don't put any white space there... moron... :-) Its an inconsequential option, pull rank, get back to work. My opinion is that it's not an inconsequential option. Putting it in can cause issues, leaving it out does nothing but rub against some people's sense of neatness and order. Given the choice I'll always vote for the one that doesn't cause issues - I'd rather have people a tiny bit uncomfortable with not having it there than finding out there's a bit of whitespace at the end of a file when it could be in one of thousands. But maybe that's just me. -Stuart -- http://stut.net/ On Fri, Jan 8, 2010 at 1:24 PM, Daevid Vincent dae...@daevid.com wrote: I'm having a debate with a co-worker about adding the final ? on a PHP page... To be honest, I am the lead, and I could pull rank and be done with the discussion, however I don't like to be that way. I would rather do the right thing. If my way of thinking is old-school (I've been coding since PHP/FI), and what he says is the newfangled proper PHP/Zend way, then I'd rather adopt that, despite how icky it makes me feel to leave an unclosed ?php just dangling and alone, all sad-like. In my mind, nobody gets left behind! :) Is there ANY side-effects to leaving the end ? off? Is it any more work for the compiler? And yes I know computers are hella-fast and all that, but I come from the gaming industry where squeeking out an extra FPS matters, and shaving off 0.01s per row of data in a table matters if you have more than 100 rows. A 1 second wait IS noticeable and a 10 second is even moreso -- just try to talk for 10 seconds straight without a pause. Or sit there and stare at a screen for 10 seconds! If the main argument is that it's to prevent white-space after the code, then most modern editors that I'm aware of will automatically trim white-space (or have a setting to do so). Plus this is ONLY a factor when you're trying to output a header and things like that. In 90% of your code, you don't deal with that. It's also obvious enough when you have an extra character/space because PHP pukes on the screen and TELLS you something about blah blah sent before header output or something to that effect. What do you guys all do? I also created a poll here http://www.rapidpoll.net/arc1opy -Original Message- From: Co-worker To: Daevid Vincent Actually, Zend states that you should omit the final ? on include pages. There is no harm in the action, and it prevents you from accidentally adding white space after the tag which will break the code. http://framework.zend.com/manual/en/coding-standard.php-file-formatting.htm l -Original Message- From: Daevid Vincent To: Co-worker Please DO include the final ? I noticed on several of your files that you have purposely omitted it. Yes, I know the files work without them, but it makes things easier to see the pairings for matching ?php . Plus it keeps things consistent and I'm not a big fan of special cases as this is, especially if it's a bad habit to get into since in all other cases it's required except this one lazy one. If you are concerned about white space sending in a header or something, well then just make sure there isn't any. I've had no problems and it makes you a more careful coder. Thanks, Daevid. -- 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 If someone is leaving whitespace all over the place that's causing those sorts of problems, then their use of ? is the least of your problems, as I suspect their code layout is probably atrocious! Getting code laid out correctly is far more important an issue than a closing ?, and when it's done correctly, you avoid a lot of problems, more than a closing ? can cause. That's a massive assumption. There are a number of editors that automatically add a blank line to the end of source files. I stand by taking the option that requires the least conscious thought from
Re: [PHP] POLL: To add the final ? or not...
At 12:24 PM -0800 1/8/10, Daevid Vincent wrote: What do you guys all do? I always close my code. I have never had a problem in doing so. I shall continue to close my code until it trips me up. At such time, I'll figure out what the problem is and fix it. Then I'll probably still close my code as is my habit. However, I think there are more important things to ponder. 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] Clean PHP 5.2.12 Build Core Dumping
I'm trying to build a clean version of php 5.2.12 on my FreeBSD 6.1 box and even with NO OPTIONS, php core dumps during the make test phase. How do I go about tracking down what is causing this problem? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Clean PHP 5.2.12 Build Core Dumping
Ok... more info on the problem... I started with a clean untarred archive, ad just ran ./configure, make, make test I get a core dump. After running gdb on the core dump I noticed it was the sqlite stuff that was dumping, so I re-ran configure with --without-sqlite --without-pdo-sqlite --with-mysql=/usr/local/mysql Now the gdb shows this: Core was generated by `php'. Program terminated with signal 11, Segmentation fault. #0 0x081d50a7 in sqlite3Select (pParse=0xbbc00080, p=0x0, eDest=164102200, iParm=0, pParent=0x24, parentTab=139141440, pParentAgg=0x84c10d8, aff=0x0) at /usr/local/directadmin/customapache/php-5.2.11/ext/pdo_sqlite/sqlite/src/sel ect.c:3172 3172 for(j=0; jpGroupBy-nExpr; j++){ First off, the compile directory listed is wrong, don't know where it got php-5.2.11 from, that's the last version I built and is installed on this system. Maybe it's pulling that from the system php? Secondly, even though I've told it not to use sqlite, it still seems to be. Any help here would be appreciated in moving forward. My whole reason for needing to rebuild php is I need the pdo_mysql module instead of the pdo_sqlite version. Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POLL: To add the final ? or not...
Hadn't paid much attention to the issue until reading a previous discussion on the topic, here on this list. After that, I decided to be consistent and leave the closing ? out in all include files. To my eyes, ? means look there is more content coming, which seems kind of silly when there isn't. A neat thing with pairing every ?php with a ? when mixed in HTML is that these are valid XML processing instructions. If your HTML satisfies XML well-formedness, your PHP document will also be valid XML. Not that I've ever had any need to process my layout templates as XML but anyway. Cheers, Mattias Daevid Vincent wrote: I'm having a debate with a co-worker about adding the final ? on a PHP page... To be honest, I am the lead, and I could pull rank and be done with the discussion, however I don't like to be that way. I would rather do the right thing. If my way of thinking is old-school (I've been coding since PHP/FI), and what he says is the newfangled proper PHP/Zend way, then I'd rather adopt that, despite how icky it makes me feel to leave an unclosed ?php just dangling and alone, all sad-like. In my mind, nobody gets left behind! :) Is there ANY side-effects to leaving the end ? off? Is it any more work for the compiler? And yes I know computers are hella-fast and all that, but I come from the gaming industry where squeeking out an extra FPS matters, and shaving off 0.01s per row of data in a table matters if you have more than 100 rows. A 1 second wait IS noticeable and a 10 second is even moreso -- just try to talk for 10 seconds straight without a pause. Or sit there and stare at a screen for 10 seconds! If the main argument is that it's to prevent white-space after the code, then most modern editors that I'm aware of will automatically trim white-space (or have a setting to do so). Plus this is ONLY a factor when you're trying to output a header and things like that. In 90% of your code, you don't deal with that. It's also obvious enough when you have an extra character/space because PHP pukes on the screen and TELLS you something about blah blah sent before header output or something to that effect. What do you guys all do? I also created a poll here http://www.rapidpoll.net/arc1opy -Original Message- From: Co-worker To: Daevid Vincent Actually, Zend states that you should omit the final ? on include pages. There is no harm in the action, and it prevents you from accidentally adding white space after the tag which will break the code. http://framework.zend.com/manual/en/coding-standard.php-file-formatting.htm l -Original Message- From: Daevid Vincent To: Co-worker Please DO include the final ? I noticed on several of your files that you have purposely omitted it. Yes, I know the files work without them, but it makes things easier to see the pairings for matching ?php . Plus it keeps things consistent and I'm not a big fan of special cases as this is, especially if it's a bad habit to get into since in all other cases it's required except this one lazy one. If you are concerned about white space sending in a header or something, well then just make sure there isn't any. I've had no problems and it makes you a more careful coder. Thanks, Daevid. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POLL: To add the final ? or not...
I would leave this to personal preference, whether there is a closing ? or not wouldn't bother me. I could argue both ways: Pro: You should put a final ? for neatness and XML compatibility. Con: It makes the script fractionally slower because 2 more characters have to be processed and there might be issues with the header when it's already sent. I've had that problem before and it's really annoying. Regards, Tim ++Tim Hinnerk Heuer++ http://www.ihostnz.com 2010/1/9 Mattias Thorslund matt...@thorslund.us Hadn't paid much attention to the issue until reading a previous discussion on the topic, here on this list. After that, I decided to be consistent and leave the closing ? out in all include files. To my eyes, ? means look there is more content coming, which seems kind of silly when there isn't. A neat thing with pairing every ?php with a ? when mixed in HTML is that these are valid XML processing instructions. If your HTML satisfies XML well-formedness, your PHP document will also be valid XML. Not that I've ever had any need to process my layout templates as XML but anyway. Cheers, Mattias Daevid Vincent wrote: I'm having a debate with a co-worker about adding the final ? on a PHP page... To be honest, I am the lead, and I could pull rank and be done with the discussion, however I don't like to be that way. I would rather do the right thing. If my way of thinking is old-school (I've been coding since PHP/FI), and what he says is the newfangled proper PHP/Zend way, then I'd rather adopt that, despite how icky it makes me feel to leave an unclosed ?php just dangling and alone, all sad-like. In my mind, nobody gets left behind! :) Is there ANY side-effects to leaving the end ? off? Is it any more work for the compiler? And yes I know computers are hella-fast and all that, but I come from the gaming industry where squeeking out an extra FPS matters, and shaving off 0.01s per row of data in a table matters if you have more than 100 rows. A 1 second wait IS noticeable and a 10 second is even moreso -- just try to talk for 10 seconds straight without a pause. Or sit there and stare at a screen for 10 seconds! If the main argument is that it's to prevent white-space after the code, then most modern editors that I'm aware of will automatically trim white-space (or have a setting to do so). Plus this is ONLY a factor when you're trying to output a header and things like that. In 90% of your code, you don't deal with that. It's also obvious enough when you have an extra character/space because PHP pukes on the screen and TELLS you something about blah blah sent before header output or something to that effect. What do you guys all do? I also created a poll here http://www.rapidpoll.net/arc1opy -Original Message- From: Co-worker To: Daevid Vincent Actually, Zend states that you should omit the final ? on include pages. There is no harm in the action, and it prevents you from accidentally adding white space after the tag which will break the code. http://framework.zend.com/manual/en/coding-standard.php-file-formatting.htm l -Original Message- From: Daevid Vincent To: Co-worker Please DO include the final ? I noticed on several of your files that you have purposely omitted it. Yes, I know the files work without them, but it makes things easier to see the pairings for matching ?php . Plus it keeps things consistent and I'm not a big fan of special cases as this is, especially if it's a bad habit to get into since in all other cases it's required except this one lazy one. If you are concerned about white space sending in a header or something, well then just make sure there isn't any. I've had no problems and it makes you a more careful coder. Thanks, Daevid. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POLL: To add the final ? or not...
Mattias Thorslund wrote: Hadn't paid much attention to the issue until reading a previous discussion on the topic, here on this list. After that, I decided to be consistent and leave the closing ? out in all include files. To my eyes, ? means look there is more content coming, which seems kind of silly when there isn't. For mixed HTML/PHP files I add the ? but for source only files I leave it off. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POLL: To add the final ? or not...
tedd wrote: At 12:24 PM -0800 1/8/10, Daevid Vincent wrote: What do you guys all do? I always close my code. I have never had a problem in doing so. I shall continue to close my code until it trips me up. At such time, I'll figure out what the problem is and fix it. Then I'll probably still close my code as is my habit. However, I think there are more important things to ponder. +1 /Per -- Per Jessen, Zürich (-4.4°C) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about using JSON_ENCODE()
Thank you Ruan! This is just what I was looking for! Anthony Ryan Sun ryansu...@gmail.com wrote in message news:f7f19ac21001081308r4b202d45vedaf3561536ad...@mail.gmail.com... Yup, you put result in an array $result = array('status' = 'good'); and return encoded string return Json_Encode($result); your client will get a string '{status: good}' and you use your client tech(eg. javascrpt) to decode this string and finall get an object On Fri, Jan 8, 2010 at 3:43 PM, Anthony Papillion papill...@gmail.comwrote: I'm developing a basic webservice to compliment a mobile application I'm developing or iPhone. While I know how to encode simple variables and arrays, I'm not sure how to do what I'm needing to do. Basically, I want to encode a status message to return to the mobile client. Something like status good_request Right now, I'm thinking I should put this in an array and encode/return that. But is that the right way of thinking? Is there a more correct or better way to do this? Thanks! Anthony -- 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