php-general Digest 5 Mar 2011 18:03:03 -0000 Issue 7212
php-general Digest 5 Mar 2011 18:03:03 - Issue 7212 Topics (messages 311683 through 311699): $GLOBALS example script on php.net 311683 by: Ashim Kapoor 311687 by: Richard Quadling 311688 by: Ashim Kapoor 311689 by: David Hutto 311697 by: Daniel Brown Re: error message for date() 311684 by: clancy_1.cybec.com.au 311685 by: Simon J Welsh Re: Returning a recordset to a desktop app 311686 by: Richard Quadling 311692 by: Ken Watkins 311693 by: Ken Watkins Re: Somewhat OT - Stored Procedures 311690 by: Florin Jurcovici 311694 by: Vivek 311695 by: Vivek Re: Double method access (Hi everyone! :)) 311691 by: Vivek Regex for extracting quoted strings 311696 by: Mark Kelly 311698 by: Nathan Rixham Re: Overriding session length in existing session? 311699 by: tedd 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--- Dear all, I was reading this page http://php.net/manual/en/reserved.variables.globals.php and I found the following script there : Here's a function which returns an array of all user defined global variables: ?php function globals() { $globals = $GLOBALS; foreach (array( 'GLOBALS', '_ENV', 'HTTP_ENV_VARS', '_POST', 'HTTP_POST_VARS', '_GET', 'HTTP_GET_VARS', '_COOKIE', 'HTTP_COOKIE_VARS', '_SERVER', 'HTTP_SERVER_VARS', '_FILES', 'HTTP_POST_FILES', '_REQUEST' ) as $var) { unset($globals[$var]); } return $globals; } ? I think that this script UNSETS each supergobal variable,but page says that it returns ALL user defined vars ? Can some one tell me how that is ? Thank you, Ashim ---End Message--- ---BeginMessage--- On 5 March 2011 05:44, Ashim Kapoor ashimkap...@gmail.com wrote: Dear all, I was reading this page http://php.net/manual/en/reserved.variables.globals.php and I found the following script there : Here's a function which returns an array of all user defined global variables: ?php function globals() { $globals = $GLOBALS; foreach (array( 'GLOBALS', '_ENV', 'HTTP_ENV_VARS', '_POST', 'HTTP_POST_VARS', '_GET', 'HTTP_GET_VARS', '_COOKIE', 'HTTP_COOKIE_VARS', '_SERVER', 'HTTP_SERVER_VARS', '_FILES', 'HTTP_POST_FILES', '_REQUEST' ) as $var) { unset($globals[$var]); } return $globals; } ? I think that this script UNSETS each supergobal variable,but page says that it returns ALL user defined vars ? Can some one tell me how that is ? Thank you, Ashim You are right. The user note is incorrect. I'll remove it. -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY ---End Message--- ---BeginMessage--- I'll remove it. How does one remove user notes from php.net ? Thank you, Ashim ---End Message--- ---BeginMessage--- On Sat, Mar 5, 2011 at 5:10 AM, Ashim Kapoor ashimkap...@gmail.com wrote: I'll remove it. How does one remove user notes from php.net ? I'd guest they had been granted access to the php.net page editor, but I may be wrong. Not that that site hasn't been scraped by other sites and added to their content, or been catalogued by google cache or alexis, etc. Thank you, Ashim -- According to theoretical physics, the division of spatial intervals as the universe evolves gives rise to the fact that in another timeline, your interdimensional counterpart received helpful advice from me...so be eternally pleased for them. ---End Message--- ---BeginMessage--- On Sat, Mar 5, 2011 at 05:42, David Hutto smokefl...@gmail.com wrote: I'd guest they had been granted access to the php.net page editor, but I may be wrong. Not that that site hasn't been scraped by other sites and added to their content, or been catalogued by google cache or alexis, etc. Richard is part of the documentation management team here in the PHP project. That's the only way you can modify or remove user notes. -- /Daniel P. Brown Network Infrastructure Manager http://www.php.net/ ---End Message--- ---BeginMessage--- After a long battle to get my system back on air after a hard disk crash, I got PHP 5.3.5 running under Apache 2.2.3. I now get a diagnostic every time I call date(), complaining about a missing parameter. The manual states that the second parameter is optional, and even phpinfo doesn't know about this new requirement, as it contains the same diagnostic: Warning: phpinfo(): It is not safe to
Re: [PHP] Returning a recordset to a desktop app
On 4 March 2011 23:48, Ken Watkins k...@atlanticbb.net wrote: Hi All. I have a Windows desktop app that I created using Visual Foxpro (a database app). I want to write a PHP script that I will call from my desktop app. The script will simply query a MySQL database on my web server and return the recordset to the desktop app. My question is simply this: What is the preferred method for passing this recordset back to the desktop app? I'm assuming that there's no reasonable way to send a recordset back without converting it to an array or XML or an object or something? How do I return the data in the recordset to the desktop app? Thanks for your advice. Ken Watkins In general terms, the output of a PHP script is going to be text (html, xml, csv, etc.) or binary (images). Getting a PHP script to communicate natively with FoxPro is not going to be trivial task. It MAY be able to be done, but hopefully FoxPro has the capability of running a PHP script via the command line ... C:\PHP5\php.exe -f script.php -- script_arg1 script_arg2 PHP can either output the result set (in an appropriate form) directly and FoxPro could read it from STDIN (if it has that support) or PHP can write the answer to a file and FoxPro can use normal file and string functions to read the data. If FoxPro has XML support, then use it. It will be much cleaner in the long run if the data changes. If not, then a tab separated data file (rather than a CSV file). This assumes that your data does not contain tabs. If so, choose another separator. Richard. -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $GLOBALS example script on php.net
On 5 March 2011 05:44, Ashim Kapoor ashimkap...@gmail.com wrote: Dear all, I was reading this page http://php.net/manual/en/reserved.variables.globals.php and I found the following script there : Here's a function which returns an array of all user defined global variables: ?php function globals() { $globals = $GLOBALS; foreach (array( 'GLOBALS', '_ENV', 'HTTP_ENV_VARS', '_POST', 'HTTP_POST_VARS', '_GET', 'HTTP_GET_VARS', '_COOKIE', 'HTTP_COOKIE_VARS', '_SERVER', 'HTTP_SERVER_VARS', '_FILES', 'HTTP_POST_FILES', '_REQUEST' ) as $var) { unset($globals[$var]); } return $globals; } ? I think that this script UNSETS each supergobal variable,but page says that it returns ALL user defined vars ? Can some one tell me how that is ? Thank you, Ashim You are right. The user note is incorrect. I'll remove it. -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $GLOBALS example script on php.net
I'll remove it. How does one remove user notes from php.net ? Thank you, Ashim
Re: [PHP] $GLOBALS example script on php.net
On Sat, Mar 5, 2011 at 5:10 AM, Ashim Kapoor ashimkap...@gmail.com wrote: I'll remove it. How does one remove user notes from php.net ? I'd guest they had been granted access to the php.net page editor, but I may be wrong. Not that that site hasn't been scraped by other sites and added to their content, or been catalogued by google cache or alexis, etc. Thank you, Ashim -- According to theoretical physics, the division of spatial intervals as the universe evolves gives rise to the fact that in another timeline, your interdimensional counterpart received helpful advice from me...so be eternally pleased for them. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Somewhat OT - Stored Procedures
Hi. I would always recommend stored procedures, as long as there are a very few rules obeyed: - keep them simple - they should mostly implement just CRUD operations plus application-specific searches, and should not encapsulate any other logic - use just portable SQL (well, as long as this is possible) My reasoning for using stored procedures and sticking to these rules is the following: - no matter what you do, especially with PHP, you can't achieve the same performance if you generate your SQL on the fly as when you just call a precompiled stored procedure - by keeping stored procedures very simple, and sticking to the convention of packing just CRUD + specialized searches into them, plus using just portable SQL, inasmuch as possible, you can easily switch databases - in most cases, just copying over the stored procedures does the trick - for the same reasons listed for the previous point, the readability of your application is much improved - reading users_getByLogin(:login) is IMO easier to comprehend than SELECT * FROM USERS WHERE loginName = :login, without sacrificing any performance or portability, compared to using inline SQL statements as strings The consequences of not sticking to the above listed two criteria can be very bad: - packing more than reasonable logic into the database makes your application incomprehensible - for instance company_doMonthEndCalculations() is likely to include such a huge quantity of logic, that the PHP code calling it is mostly irrelevant, and you must actually comprehend both the details of the SQL in the database (in the stored procedures) and the way PHP is connecting them to understand an application - obviously harder if you have all your logic in just one place - using non-portable SQL may be quite a deterrent from porting to a new database, or may cause a lot more effort than needed, and isn't in fact justified in most cases - whereas if packing only very specific and simple operations into stored procedures allows you to keep the design of the PHP application very object-oriented, packing very much logic into stored procedures may cause your PHP code to be just an adapter to an application written in SQL, instead of being the application itself; SQL being procedural, your application will have all the flexibility, extensibility and maintainability problems that a non-OO design causes br, flj -- Fine counsel is confusing, but example is always clear. (Edgar A. Guest, The Light of Faith) PS: I'm not trying to be a smart-ass, but IMO stored procedures are underrated (not just by PHP programmers), and it's a pity (and it leads to sub-optimal applications, and to the development of cures for the symptoms instead of the cause, at least on other platforms than PHP), and not letting a database do what it does best is simply stupid. That's why I try advertising their use whenever I have an opportunity. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Double method access (Hi everyone! :))
I also totally agree with Larry that if used judiciously then method/object chaining can give great results, else otherwise, can create a lot of overhead in the application. Netemp On Sat, Mar 5, 2011 at 1:14 AM, Paola Alvarez paola.alvare...@gmail.comwrote: Hi, thanks a lot Alex and Larry for your very clear answer! Paola, On Fri, Mar 4, 2011 at 4:33 PM, la...@garfieldtech.com la...@garfieldtech.com wrote: That's called method chaining. -getColumns() will get called on the object returned by -getTable(). That is, getTable() returns an object (presumably representing an SQL table, I guess), and that object has a getColumns() method, which you call. This is an extremely common style in Javascript code that has been gaining widespread use in PHP OO circles in recent years. If leveraged properly it can create very compact, very readable, very powerful code. (And if done stupidly can lead to a horrid mess, but that's true of any coding style.) --Larry Garfield On 3/4/11 1:25 PM, Paola Alvarez wrote: Hi there!, I have been reading this list before but this is my first post. Reading some code from Symfony I got this: $this-getTable()-getColumns() ...when you can use this double method access?, I used before the regular $this-getTable(), but two?. I mean I have been trying but I got an error* * Fatal error: Call to a member function ... on a non-object in ... Thanks! Paola PS: BTW, sorry my english isnt really good -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Returning a recordset to a desktop app
Larry, Yes, the PHP script will reside on my web server along with the MySQL database. I assumed that I would call the script over HTTP, but I guess that is part of my question too. Foxpro allows you to embed controls in its forms, and one of them is a browser control. But I don't really want to echo anything to the enduser, I just want to capture the data behind the scenes, so to speak. I think I can handle that with the browser control. If I understand you correctly, when I do an echo statement or a print statement (or a return()?), it will return the data to the desktop app. And the best way to return it is in xml. I'll investigate the methods you mention for converting xml since I'm not familiar with any of them. Thanks! Ken On 3/4/2011 6:51 PM, la...@garfieldtech.com wrote: Assuming you mean that the PHP script is on a web server somewhere and the desktop app is hitting it over HTTP, it's no different than any other response. Anything you print will be sent back to the client, in this case your desktop a.. So if you want to send XML back, you'd build a string with your XML (either manually or using the DOM or SimpleXML APIs or a 3rd party like QueryPath or whatever floats your boat) and print it, just as you would HTML. Note that you may need to explicitly set headers with header() to make sure the desktop app reads it properly. --Larry Garfield On 3/4/11 5:48 PM, Ken Watkins wrote: Hi All. I have a Windows desktop app that I created using Visual Foxpro (a database app). I want to write a PHP script that I will call from my desktop app. The script will simply query a MySQL database on my web server and return the recordset to the desktop app. My question is simply this: What is the preferred method for passing this recordset back to the desktop app? I'm assuming that there's no reasonable way to send a recordset back without converting it to an array or XML or an object or something? How do I return the data in the recordset to the desktop app? Thanks for your advice. Ken Watkins -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Returning a recordset to a desktop app
On 3/5/2011 4:30 AM, Richard Quadling wrote: On 4 March 2011 23:48, Ken Watkins k...@atlanticbb.net wrote: Hi All. I have a Windows desktop app that I created using Visual Foxpro (a database app). I want to write a PHP script that I will call from my desktop app. The script will simply query a MySQL database on my web server and return the recordset to the desktop app. My question is simply this: What is the preferred method for passing this recordset back to the desktop app? I'm assuming that there's no reasonable way to send a recordset back without converting it to an array or XML or an object or something? How do I return the data in the recordset to the desktop app? Thanks for your advice. Ken Watkins In general terms, the output of a PHP script is going to be text (html, xml, csv, etc.) or binary (images). Getting a PHP script to communicate natively with FoxPro is not going to be trivial task. It MAY be able to be done, but hopefully FoxPro has the capability of running a PHP script via the command line ... C:\PHP5\php.exe -f script.php -- script_arg1 script_arg2 PHP can either output the result set (in an appropriate form) directly and FoxPro could read it from STDIN (if it has that support) or PHP can write the answer to a file and FoxPro can use normal file and string functions to read the data. If FoxPro has XML support, then use it. It will be much cleaner in the long run if the data changes. If not, then a tab separated data file (rather than a CSV file). This assumes that your data does not contain tabs. If so, choose another separator. Richard. Richard, Foxpro does have XML support, so you answered that part of my question, thanks. And it is capable of calling any other executable on the local machine through the local OS shell - which seems to be what you are advocating. But I'm not sure how I would do that over the internet. I just discussed this issue with Larry, and I assume that I would use HTTP? Or is there a way to call a command line script on a remote web server without using HTTP? Sorry if this is a stupid question. Thanks for your help! Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Somewhat OT - Stored Procedures
Hi Team I very much agree with the points shared by Florin (esp. the two rules). But unfortunately, these rules are not standards and that is where the real problem lies. The injudicious use of SPs leads to un-manageable code which is rarely portable (real life situations J which are too common to be overlooked). Hoping that everyone will stick to and follow the best practices while creating code. Regards NetEmp On Sat, Mar 5, 2011 at 6:01 PM, Florin Jurcovici florin.jurcov...@gmail.com wrote: Hi. I would always recommend stored procedures, as long as there are a very few rules obeyed: - keep them simple - they should mostly implement just CRUD operations plus application-specific searches, and should not encapsulate any other logic - use just portable SQL (well, as long as this is possible) My reasoning for using stored procedures and sticking to these rules is the following: - no matter what you do, especially with PHP, you can't achieve the same performance if you generate your SQL on the fly as when you just call a precompiled stored procedure - by keeping stored procedures very simple, and sticking to the convention of packing just CRUD + specialized searches into them, plus using just portable SQL, inasmuch as possible, you can easily switch databases - in most cases, just copying over the stored procedures does the trick - for the same reasons listed for the previous point, the readability of your application is much improved - reading users_getByLogin(:login) is IMO easier to comprehend than SELECT * FROM USERS WHERE loginName = :login, without sacrificing any performance or portability, compared to using inline SQL statements as strings The consequences of not sticking to the above listed two criteria can be very bad: - packing more than reasonable logic into the database makes your application incomprehensible - for instance company_doMonthEndCalculations() is likely to include such a huge quantity of logic, that the PHP code calling it is mostly irrelevant, and you must actually comprehend both the details of the SQL in the database (in the stored procedures) and the way PHP is connecting them to understand an application - obviously harder if you have all your logic in just one place - using non-portable SQL may be quite a deterrent from porting to a new database, or may cause a lot more effort than needed, and isn't in fact justified in most cases - whereas if packing only very specific and simple operations into stored procedures allows you to keep the design of the PHP application very object-oriented, packing very much logic into stored procedures may cause your PHP code to be just an adapter to an application written in SQL, instead of being the application itself; SQL being procedural, your application will have all the flexibility, extensibility and maintainability problems that a non-OO design causes br, flj -- Fine counsel is confusing, but example is always clear. (Edgar A. Guest, The Light of Faith) PS: I'm not trying to be a smart-ass, but IMO stored procedures are underrated (not just by PHP programmers), and it's a pity (and it leads to sub-optimal applications, and to the development of cures for the symptoms instead of the cause, at least on other platforms than PHP), and not letting a database do what it does best is simply stupid. That's why I try advertising their use whenever I have an opportunity. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Somewhat OT - Stored Procedures
Hi Team I very much agree with the points shared by Florin (esp. the two rules). But unfortunately, these rules are not standards and that is where the real problem lies. The injudicious use of SPs leads to un-manageable code which is rarely portable (real life situations J which are too common to be overlooked). Hoping that everyone will stick to and follow the best practices while creating code. Regards NetEmp On Sat, Mar 5, 2011 at 6:01 PM, Florin Jurcovici florin.jurcov...@gmail.com wrote: Hi. I would always recommend stored procedures, as long as there are a very few rules obeyed: - keep them simple - they should mostly implement just CRUD operations plus application-specific searches, and should not encapsulate any other logic - use just portable SQL (well, as long as this is possible) My reasoning for using stored procedures and sticking to these rules is the following: - no matter what you do, especially with PHP, you can't achieve the same performance if you generate your SQL on the fly as when you just call a precompiled stored procedure - by keeping stored procedures very simple, and sticking to the convention of packing just CRUD + specialized searches into them, plus using just portable SQL, inasmuch as possible, you can easily switch databases - in most cases, just copying over the stored procedures does the trick - for the same reasons listed for the previous point, the readability of your application is much improved - reading users_getByLogin(:login) is IMO easier to comprehend than SELECT * FROM USERS WHERE loginName = :login, without sacrificing any performance or portability, compared to using inline SQL statements as strings The consequences of not sticking to the above listed two criteria can be very bad: - packing more than reasonable logic into the database makes your application incomprehensible - for instance company_doMonthEndCalculations() is likely to include such a huge quantity of logic, that the PHP code calling it is mostly irrelevant, and you must actually comprehend both the details of the SQL in the database (in the stored procedures) and the way PHP is connecting them to understand an application - obviously harder if you have all your logic in just one place - using non-portable SQL may be quite a deterrent from porting to a new database, or may cause a lot more effort than needed, and isn't in fact justified in most cases - whereas if packing only very specific and simple operations into stored procedures allows you to keep the design of the PHP application very object-oriented, packing very much logic into stored procedures may cause your PHP code to be just an adapter to an application written in SQL, instead of being the application itself; SQL being procedural, your application will have all the flexibility, extensibility and maintainability problems that a non-OO design causes br, flj -- Fine counsel is confusing, but example is always clear. (Edgar A. Guest, The Light of Faith) PS: I'm not trying to be a smart-ass, but IMO stored procedures are underrated (not just by PHP programmers), and it's a pity (and it leads to sub-optimal applications, and to the development of cures for the symptoms instead of the cause, at least on other platforms than PHP), and not letting a database do what it does best is simply stupid. That's why I try advertising their use whenever I have an opportunity. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Vivek 88 6096 7077
[PHP] Regex for extracting quoted strings
Hi. I'm hoping someone can help me extract text between double quotes from a string. $regex = 'some magic'; $r = preg_match($regex, $sentence, $phrases); So, if $sentence = 'Dave said This is it. Nope, that is the wrong colour she replied.'; I want $phrases to contain 'This is it' and 'Nope, that is the wrong colour'. Can anyone help? Cheers, Mark -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $GLOBALS example script on php.net
On Sat, Mar 5, 2011 at 05:42, David Hutto smokefl...@gmail.com wrote: I'd guest they had been granted access to the php.net page editor, but I may be wrong. Not that that site hasn't been scraped by other sites and added to their content, or been catalogued by google cache or alexis, etc. Richard is part of the documentation management team here in the PHP project. That's the only way you can modify or remove user notes. -- /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] Re: Regex for extracting quoted strings
Mark Kelly wrote: Hi. I'm hoping someone can help me extract text between double quotes from a string. $regex = 'some magic'; $r = preg_match($regex, $sentence, $phrases); So, if $sentence = 'Dave said This is it. Nope, that is the wrong colour she replied.'; I want $phrases to contain 'This is it' and 'Nope, that is the wrong colour'. Can anyone help? $regex = '/(.*)/imU'; $r = preg_match_all($regex, $sentence, $phrases); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Overriding session length in existing session?
At 5:00 PM -0800 3/3/11, Scott Baker wrote: On 03/03/2011 04:31 PM, tedd wrote: Simple answer -- put session_start() at the start of your code -- first line. Of index.php or header.php? You lost me. -- Scott Baker - Canby Telcom Scott: The statement should be at the start of every php file that has php code in it. For example, if you have three web pages (index.php, services.php, and contact.php) AND you have php code in each that share session data, then the first statement in every page should be: ?php session_start; Here's a working example: http://www.webbytedd.com/b/sessions/index.php The code is there. Cheers, tedd -- --- http://sperling.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Overriding session length in existing session?
The statement should be at the start of every php file that has php code in it. Hi Tedd, Normally I'd agree with this but having never used the function session_set_cookie_params() before, I looked it up, and the manual says to put it before session_start(). Set cookie parameters defined in the php.ini file. The effect of this function only lasts for the duration of the script. Thus, you need to call session_set_cookie_params() for every request and before session_start() is called. Marc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Is 5.3.5 really that much slower than 5.2?
Hi list, I've been getting my code base ready to upgrade from 5.2 to 5.3 for all the great features and supposed performance and memory improvements, but with regular usage (ie. on my production servers) I just don't see those improvements. With 5.2 pages load on average of 2ms and consume between 256-512k of memory at peak. The same pages under 5.3.5 take on average 4ms and consume about 1.2mb of memory at peak. The only difference in the config is that 5.3 is using mysqli with msqlnd, while the 5.2 is using libmysql for mysqli. I understand that mysqlnd should make things faster and use more memory (using PHP's native memory for storing data), but these are on pages with no database connections at all. They're pretty complicated pages with very little OO and with lots of small pieces coming from file caches. I'm guessing that 5.3 might be faster in heavy OO usage, but I can't see how a big shop can simply upgrade from 5.2 to 5.3 without performance being a big concern. Those numbers might not appear big, but they make a huge difference when serving thousands of requests/s. Are there practical reasons why 5.3 is so much slower? Is there a trick to making it behave better, or do I simply have to stick with 5.2 until it's no longer supported? Is anyone else out there in the same boat? Thanks! Joel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Overriding session length in existing session?
At 1:29 PM -0500 3/5/11, Marc Guay wrote: The statement should be at the start of every php file that has php code in it. Hi Tedd, Normally I'd agree with this but having never used the function session_set_cookie_params() before, I looked it up, and the manual says to put it before session_start(). Set cookie parameters defined in the php.ini file. The effect of this function only lasts for the duration of the script. Thus, you need to call session_set_cookie_params() for every request and before session_start() is called. Marc Marc: Okay, but read on -- there seems to be debate on it. Cheers, tedd -- --- http://sperling.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Regex for extracting quoted strings
On 03/05/2011 09:26 AM, Mark Kelly wrote: Hi. I'm hoping someone can help me extract text between double quotes from a string. $regex = 'some magic'; $r = preg_match($regex, $sentence, $phrases); So, if $sentence = 'Dave said This is it. Nope, that is the wrong colour she replied.'; I want $phrases to contain 'This is it' and 'Nope, that is the wrong colour'. Can anyone help? Cheers, Mark $regex = '/([^]+)/'; -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Regex for extracting quoted strings
On 6/03/2011, at 11:08 AM, Shawn McKenzie wrote: On 03/05/2011 09:26 AM, Mark Kelly wrote: Hi. I'm hoping someone can help me extract text between double quotes from a string. $regex = 'some magic'; $r = preg_match($regex, $sentence, $phrases); So, if $sentence = 'Dave said This is it. Nope, that is the wrong colour she replied.'; I want $phrases to contain 'This is it' and 'Nope, that is the wrong colour'. Can anyone help? Cheers, Mark $regex = '/([^]+)/'; -- Thanks! -Shawn http://www.spidean.com Also, you'll want preg_match_all rather than preg_match. --- Simon Welsh Admin of http://simon.geek.nz/ Who said Microsoft never created a bug-free program? The blue screen never, ever crashes! http://www.thinkgeek.com/brain/gimme.cgi?wid=81d520e5e -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Regex for extracting quoted strings
Hi. Thanks for all the replies. On Saturday 05 Mar 2011 at 22:11 Simon J Welsh wrote: On 6/03/2011, at 11:08 AM, Shawn McKenzie wrote: $regex = '/([^]+)/'; Shawn, this regex gets me two copies of each string - one with and one without the double quotes - as did the one Nathan posted earlier. Also, you'll want preg_match_all rather than preg_match. Yeah, I realised that quite early on in my messing about. What I have ended up with is: $regex = '/.*?/'; $found = preg_match_all($regex, $sentence, $phrases); This still leaves the quotes in the phrases, but at least I only get one copy of each phrase. I'm just trimming the quotes afterwards. Thanks for all the advice. Mark -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $GLOBALS example script on php.net
Dear Ashley, I do follow the part when it creates a local copy of $GLOBALS. When it unsets them, is there a subtlety of unset that it ONLY unsets system defined entries? Could you please explain this ? Thank you, Ashim
Re: [PHP] Re: Regex for extracting quoted strings
Maybe this will help. $regex = '/(?=)[^.]*(?=)/'; $r = preg_match_all($regex, $sentence, $phrases);
Re: [PHP] PHP5.3.5: error message for date()
On Sat, 5 Mar 2011 20:42:07 +1300, si...@welsh.co.nz (Simon J Welsh) wrote: On 5/03/2011, at 8:29 PM, clanc...@cybec.com.au wrote: After a long battle to get my system back on air after a hard disk crash, I got PHP 5.3.5 running under Apache 2.2.3. I now get a diagnostic every time I call date(), complaining about a missing parameter. The manual states that the second parameter is optional, and even phpinfo doesn't know about this new requirement, as it contains the same diagnostic: Warning: phpinfo(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Australia/Melbourne' for '11.0/DST' instead in D:\Websites\index.php on line 1 Warning: phpinfo(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Australia/Melbourne' for '11.0/DST' instead in D:\Websites\index.php on line 1 . Is this a bug, or a new requirement we will have to get used to? Roger Riordan AM It's not complaining about a missing parameter, it's complaining about the lack of a specified timezone. This warning was introduced in PHP5.1, and you either need to set the date.timezone INI setting, either in your php.ini or by using ini_set(), or by passing a valid timezone to date_default_timezone_set() before calling any other date-related functions. --- Simon Welsh Admin of http://simon.geek.nz/ Who said Microsoft never created a bug-free program? The blue screen never, ever crashes! http://www.thinkgeek.com/brain/gimme.cgi?wid=81d520e5e Thanks for this. I have put date_default_timezone_set() at the start of my program, which clears up all my bugs, but leaves the bug in PHP.ini. This doesn't worry me. And now I know where my son found the 10 types of people T-shirt. Unfortunately I seldom wear T-shirts, and my friends wouldn't get the joke anyway. With my best wishes, -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5.3.5: error message for date()
PS. What is date.sunrise_zenith? I am surprised that PHP contains a function to return the time of sunrise for a given location, but I thought that latitude, longitude, date and time zone would be all you had to know. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php