Re: [PHP] Reports generator
Thanks Paul and Renee! Paul: I am not up to par on my SQL joins, I have to get another book this weekend; I knew that joins would be almost necessary for what I'm trying to accomplish. Iterative development, while painstaking, seems like the hands on approach I'm used to, and has proven effective in the past when developing complicated procedures. On a side note: the application I am developing is turning out to be many, many times larger than I anticipated, and I am learning OO concepts as I go along. Occasionally I have to rewrite code, and take the opportunity to improve in other areas (eg. I was using 2 versions of a session management include, and when I moved to a new improved one I made sure every page had another new include which defined a ROOT constant*). Now and then I take a day to move iterative code into classes. Renee: I think your idea of a superclass (hat-tip: Paul also mentioned an inheritance approach) and child classes is going to be necessary. Originally I was thinking of a handler class (all Reports) and a singular (NOT singleton) class (a single report), but that led me to other questions and distracted me from productive thought. To be fair Renee, I couldn't follow what you were saying about your newsscraper class (I've heard of curl, but not much more than that, and what do you mean by 'parsing'?). My application is meant to replace faxed order forms and Excel spreadsheets (my associate does A TON of copy/paste when dealing with seat orders). So this needs to be flexible enough to be a viable alternative. So far it is far superior in many respects, but in others it is lacking. Liiike printing out an excel spreadsheet is as easy as Ctrl+P, so to achieve this end I have to generate a report for a bare bones html page to print. SIDE QUESTION: What do you think of my use of serialization? I don't see a need to store duplicate information in new tables, and thought serializing these one shot reports the best solution. Thanks again everyone! Allen *The include that defined a ROOT constant accomplished something I saw someone else do, and it's genius (perhaps elementary to you experts). It is so rudimentary I can't believe I hadn't thought of it: it searches for a specific file config.php by using a while loop and the file_exists() function, and on each iteration it adds a ../ to the file name (../config.php becomes ../../config.php) until it finds it (maximum of 5 levels up). Once it finds it, it assigns the ../ path to the ROOT constant, so I can easily access my ROOT folder from anywhere in my script, eg. link rel=stylesheet href=?php echo ROOT ?lib/css/layout.css / On Wed, Jan 27, 2010 at 9:57 PM, Rene Veerman rene7...@gmail.com wrote: Allen, i think your primary design consideration is this; - Need to be able to build a large variety of reports based on existing data This would lead me to jump at a 'plugin' solution. I'd make: - 1 superclass as interface to the rest of your webapp(s) - 1 top-class that has the logic applicable to all reports. (or just 1 top-level class, if you want) - 1 to many plugin classes, that all use the same simple interfaces. By using arrays as options/return-results, the whole thing becomes extensible without breaking compatibility. I'm working on a newsscraper (same problem basically, doing both input to db and output from it) and for that i'm not even using classes. I'm using plain-old functions with a specific naming convention in files, also named according to a convention. Some examples of plugin functions exposed in 'plugin.news.digg.php': function plugin__news__digg__pages($mp) function plugin__news__digg__isValidPage ($page, $pageContent) function plugin__news__digg__parser__siteHTML ($page, $pageContent) $mp = user-level parameters (from the superclass) __pages returns a simple array that tells the top-class which pages to curl (and with which parser-function (like __parser__siteHTML)), before passing $pageContent along with $page (a conventionized meta-data array, mostly built up by __pages) to the parser function __parser__siteHTML. All parser functions return an array that the top-level class can use to insert their hits into the db. Plugin functions can be called by $func = 'plugin__news__digg__parser__siteHTML'; $func ($page, $pageContent); In your case, Allen, i'd start with plugins that accept user-level parameters (both generic and specific in the same $options array, and to prevent confusion through feature-creep, use more than 1 level in the array) and then output HTML. Try to use CSS effectively. Using the smarty library in plugins' HTML generation functions is probably overkill, but some people like such midware. Your top-level class can take care of any caching of finished reports. Your superclass is responsible for building up the frame of the webpage that holds the reports. If two or more plugins need (almost) the same data, consider building a datastore
[PHP] Re: Curious PHP cli output in context of bash completion ?
OK : I just recompiled, under Ubuntu 8.04, the same php version that the distribution provides, used the same php.ini and it works... I didn't applied the same patchs or even setted the same compilation options but for me it's clear that it is a distribution problem. I still do not know what exactly differs and makes the problem appear. Maybe some PHP expert could orient me to the right direction (I'm not a Guru of compilation, especiallly for PHP ...) ? Thanks 2010/1/27 Alexandre Simon lexsi...@gmail.com Hello, I'm pretty sure (in realty I do not understand a lot about the problem... :( ) this is a distribution or a version problem but maybe some PHP/bash expert here could have some idea and tell me what I could try to solve the problem described here : http://ubuntuforums.org/showthread.php?p=8734334 Shortly : PHP cli seems to output something like newlines that bash can not intercept. My initial goal is to complete a PHP script, using the PHP script itselfs as function for bash completion. Mechanism that works perfectly on some other platforms (with different PHP AND bash version ...) than Ubuntu 8.04 and 9.10 (PHP 5.2.4 and PHP 5.2.10 respectively). The interest : only one thing to code : the php script. Moreover : the PHP scripts knows things (DB connection, .. etc) that the bash script would have some difficulty to get. Thank you a lot for any help. -- Alex -- SIMON Alexandre
Re: [PHP] Replacing accented characters?
On 28.01.2010 03:40, Paul M Foster wrote: On Wed, Jan 27, 2010 at 04:55:46PM -0600, Skip Evans wrote: Hey all, I'm looking for recommendations on how to replace accented characters, like e and u with those two little dots above them, with the regular e and u characters. FWIW, those two dots are called an umlaut. Paul FWIW, the whole letters ÄäÖöÜü are called Umlaute (umlauts). The two dots above *these* letters are Umlautzeichen (umlaut marks). But two dots above an e or i are called Trema (diacritic mark). Marcus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Reports generator
On 26 January 2010 17:54, PEPITOVADECURT pepitovadec...@gmail.com wrote: Exists any reports generator that exports directly to html/php? Depending upon your platform, you have the option of using an external report generator and invoking it appropriately from within PHP. I'm on Windows and use Crystal Reports via PHP support of COM. I then output the reports to MS Word, MS Excel, HTML or PDF - depending upon the report/requirement/etc. Due to the interface provided by Crystal, you can create an entire report programmatically. It is a LOT of work, but it can be done. -- - Richard Quadling Standing on the shoulders of some very clever giants! EE : http://www.experts-exchange.com/M_248814.html EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Pointers For Newbies, Reminders For Oldies
-Original Message- From: Rene Veerman [mailto:rene7...@gmail.com] Sent: 27 January 2010 22:46 And if your script needs to pass large ( 5Mb) arrays around to functions, be sure to use passing-by-reference; failing to do so can double your memory requirements, possibly hitting the ini_set('memory_lmit', ??) Have you benchmarked this? PHP's copy-on-change philosophy means there shouldn't be much difference in memory terms -- so unless you actually expect to change the array's contents, you should pass by value. As proof, I constructed this little test: function test($arg, $base_mem) { echo Additional inside func = , memory_get_usage()-$base_mem, br /\n; } $mem_start = memory_get_usage(); $array = array_fill(1,1000,The quick brown fox jumps over the lazy dog); $mem_array = memory_get_usage(); echo After array creation = , $mem_array-$mem_start, br /\n; test($array, $mem_array); echo Final = , memory_get_usage()-$mem_start, br /\n; Which produced: After array creation = 546104 Additional inside func = 208 Final = 546312 Changing the function definition to have $arg instead of just $arg changed this to: After array creation = 545984 Additional inside func = 208 Final = 546192 In other words, there was no difference in the memory used to call a function with a by-reference argument vs a by-value argument, but the by-value version occupied an additional 120 bytes overall (which is hardly going to break the bank!). (By varying the numbers in the array_fill(), I found some minor variations, but nothing significant.) Much more interesting is adding the following line to the beginning of the function: $x = count($arg); In this case, the by-value figures were: After array creation = 546104 Additional inside func = 280 Final = 546384 ... but by-reference gave: After array creation = 545984 Additional inside func = 64600 Final = 610456 In other words, just using count() on the array increased memory usage for the by-*reference* version by over 60 kbytes, whereas the by-value version only went up by 72 bytes. Finally, I ran a quick benchmark of runtimes for a version of the function that just returns a single element of the array, which doesn't incur the ballooning memory demonstrated above. For 10,000 calls to the function (in a for loop, and averaged over several runs), the respective times were: By value:5.54sec By reference:5.64sec Or, the by-value version was very, very slightly quicker. All in all, there is no evidence that passing arrays to functions by value is inherently more expensive than by reference, and in fact in some cases it can be significantly cheaper. Which in turn says that you should only pass arguments by reference when you actually expect to change them, which is after all what the by-reference operator is there for in the first place! QED. Cheers! Mike -- Mike Ford, Electronic Information Developer, Libraries and Learning Innovation, Leeds Metropolitan University, C507, Civic Quarter Campus, Woodhouse Lane, LEEDS, LS1 3HE, United Kingdom Email: m.f...@leedsmet.ac.uk Tel: +44 113 812 4730 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Reports generator
It's Rene, not Renee :p curl is a method of fetching http pages from within php (and other languages). with parsing i meant parse(process) a html page into (in my case) an array of hits found on that page. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Pointers For Newbies, Reminders For Oldies
Thanks for your research Mike, i'm a bit puzzled. I have a custom random-array generator that i use to fill the available memory to it's max, about 1.5G on a 2G system, then passing it to a recursive json string generator. Not passing by reference did double my memory requirements, but i've changed about 7-10 functions so i dont know which one was the pig.. On Thu, Jan 28, 2010 at 12:41 PM, Ford, Mike m.f...@leedsmet.ac.uk wrote: -Original Message- From: Rene Veerman [mailto:rene7...@gmail.com] Sent: 27 January 2010 22:46 And if your script needs to pass large ( 5Mb) arrays around to functions, be sure to use passing-by-reference; failing to do so can double your memory requirements, possibly hitting the ini_set('memory_lmit', ??) Have you benchmarked this? PHP's copy-on-change philosophy means there shouldn't be much difference in memory terms -- so unless you actually expect to change the array's contents, you should pass by value. As proof, I constructed this little test: function test($arg, $base_mem) { echo Additional inside func = , memory_get_usage()-$base_mem, br /\n; } $mem_start = memory_get_usage(); $array = array_fill(1,1000,The quick brown fox jumps over the lazy dog); $mem_array = memory_get_usage(); echo After array creation = , $mem_array-$mem_start, br /\n; test($array, $mem_array); echo Final = , memory_get_usage()-$mem_start, br /\n; Which produced: After array creation = 546104 Additional inside func = 208 Final = 546312 Changing the function definition to have $arg instead of just $arg changed this to: After array creation = 545984 Additional inside func = 208 Final = 546192 In other words, there was no difference in the memory used to call a function with a by-reference argument vs a by-value argument, but the by-value version occupied an additional 120 bytes overall (which is hardly going to break the bank!). (By varying the numbers in the array_fill(), I found some minor variations, but nothing significant.) Much more interesting is adding the following line to the beginning of the function: $x = count($arg); In this case, the by-value figures were: After array creation = 546104 Additional inside func = 280 Final = 546384 ... but by-reference gave: After array creation = 545984 Additional inside func = 64600 Final = 610456 In other words, just using count() on the array increased memory usage for the by-*reference* version by over 60 kbytes, whereas the by-value version only went up by 72 bytes. Finally, I ran a quick benchmark of runtimes for a version of the function that just returns a single element of the array, which doesn't incur the ballooning memory demonstrated above. For 10,000 calls to the function (in a for loop, and averaged over several runs), the respective times were: By value:5.54sec By reference:5.64sec Or, the by-value version was very, very slightly quicker. All in all, there is no evidence that passing arrays to functions by value is inherently more expensive than by reference, and in fact in some cases it can be significantly cheaper. Which in turn says that you should only pass arguments by reference when you actually expect to change them, which is after all what the by-reference operator is there for in the first place! QED. Cheers! Mike -- Mike Ford, Electronic Information Developer, Libraries and Learning Innovation, Leeds Metropolitan University, C507, Civic Quarter Campus, Woodhouse Lane, LEEDS, LS1 3HE, United Kingdom Email: m.f...@leedsmet.ac.uk Tel: +44 113 812 4730 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm -- 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] Pointers For Newbies, Reminders For Oldies
Ford, Mike wrote: -Original Message- From: Rene Veerman [mailto:rene7...@gmail.com] Sent: 27 January 2010 22:46 And if your script needs to pass large ( 5Mb) arrays around to functions, be sure to use passing-by-reference; failing to do so can double your memory requirements, possibly hitting the ini_set('memory_lmit', ??) Have you benchmarked this? PHP's copy-on-change philosophy means there shouldn't be much difference in memory terms -- so unless you actually expect to change the array's contents, you should pass by value. As proof, I constructed this little test: function test($arg, $base_mem) { echo Additional inside func = , memory_get_usage()-$base_mem, br /\n; } try changing this to access the array in some way such as: function test($arg, $base_mem) { foreach( $arg as $index = $value ) { } echo Additional= , memory_get_usage()-$base_mem, \n; } After array creation = 52696 Additional = 101152 Final = 117200 vs: function test($arg, $base_mem) After array creation = 52696 Additional = 53104 Final = 101696 there's the double memory usage -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Replacing accented characters?
At 12:17 PM +0100 1/28/10, Marcus Gnaß wrote: On 28.01.2010 03:40, Paul M Foster wrote: On Wed, Jan 27, 2010 at 04:55:46PM -0600, Skip Evans wrote: Hey all, I'm looking for recommendations on how to replace accented characters, like e and u with those two little dots above them, with the regular e and u characters. FWIW, those two dots are called an umlaut. Paul FWIW, the whole letters ÄäÖöÜü are called Umlaute (umlauts). The two dots above *these* letters are Umlautzeichen (umlaut marks). But two dots above an e or i are called Trema (diacritic mark). Marcus On what other list could we learn that? Thanks, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Pointers For Newbies, Reminders For Oldies
-Original Message- From: Nathan Rixham [mailto:nrix...@gmail.com] Sent: 28 January 2010 13:43 Ford, Mike wrote: -Original Message- From: Rene Veerman [mailto:rene7...@gmail.com] Sent: 27 January 2010 22:46 And if your script needs to pass large ( 5Mb) arrays around to functions, be sure to use passing-by-reference; failing to do so can double your memory requirements, possibly hitting the ini_set('memory_lmit', ??) Have you benchmarked this? PHP's copy-on-change philosophy means there shouldn't be much difference in memory terms -- so unless you actually expect to change the array's contents, you should pass by value. As proof, I constructed this little test: function test($arg, $base_mem) { echo Additional inside func = , memory_get_usage()- $base_mem, br /\n; } try changing this to access the array in some way such as: function test($arg, $base_mem) { foreach( $arg as $index = $value ) { } echo Additional= , memory_get_usage()-$base_mem, \n; } After array creation = 52696 Additional = 101152 Final = 117200 vs: function test($arg, $base_mem) After array creation = 52696 Additional = 53104 Final = 101696 there's the double memory usage H'mm, that's interesting! I'm not surprised about foreach causing greater memory usage, as it's defined to operate on its own copy of the array. However, when I run the same test, I get: After array creation = 546104 Additional inside func = 64504 Final = 610336 Vs After array creation = 545984 Additional inside func = 376 Final = 546360 So here I agree that the reference version is less memory intensive, but I don't see anything like a doubling of memory even for the non-reference version. I guess it depends exactly what you do inside the function/loop. I also wonder if it's different for PHP versions -- I'm on 5.2.5. I did originally do a test of straight access, such as $x = $arg[$i], with no significant effect on my results, but I didn't think about the foreach wrinkle. Out of interest, I've just run a test using a plain for loop (with a hardcoded limit, to avoid distortion caused by count()!!), which yields: Additional inside func = 328 and Additional inside func = 328 So it definitely looks like the foreach that's causing the memory bloat! This all just goes to show that you can't always second-guess the best strategy, and, unless you're really tight for some resource, you probably might just as well program in the way that feels most natural to you! Happy programming, one and all! Cheers! Mike -- Mike Ford, Electronic Information Developer, Libraries and Learning Innovation, Leeds Metropolitan University, C507, Civic Quarter Campus, Woodhouse Lane, LEEDS, LS1 3HE, United Kingdom Email: m.f...@leedsmet.ac.uk Tel: +44 113 812 4730 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Replacing accented characters?
tedd wrote: At 12:17 PM +0100 1/28/10, Marcus Gnaß wrote: On 28.01.2010 03:40, Paul M Foster wrote: On Wed, Jan 27, 2010 at 04:55:46PM -0600, Skip Evans wrote: Hey all, I'm looking for recommendations on how to replace accented characters, like e and u with those two little dots above them, with the regular e and u characters. FWIW, those two dots are called an umlaut. Paul FWIW, the whole letters ÄäÖöÜü are called Umlaute (umlauts). The two dots above *these* letters are Umlautzeichen (umlaut marks). But two dots above an e or i are called Trema (diacritic mark). Marcus On what other list could we learn that? A linguistics list I'd wager. :B 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
[PHP] 120 meg of json analyzed by the browser...
Hi.. I've built http://mediabeez.ws/htmlMicroscope/ (lgpl), which provides a way to look at very big arrays in the browser. I'm kinda stuck at a 120 - 200Mb data-size limit, and have exhausted all my ideas on how to increase that limit further. My reasoning is that i have a gigabyte free memory on my machine, and want to use that to look at an array of at least 800mb. I know, it's a totally academic feature at the moment. But still, i would like feedback on how to increase the datasize limit to actual-free-RAM. If it's at all possible. I would greatly appreciate feedback from webbrowser developers. If you have some time and energy, please download the 1.3.0-beta on my site, and have a look to see if you can find something to improve. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Pointers For Newbies, Reminders For Oldies
Nathan Rixham wrote: Ford, Mike wrote: -Original Message- From: Rene Veerman [mailto:rene7...@gmail.com] Sent: 27 January 2010 22:46 And if your script needs to pass large ( 5Mb) arrays around to functions, be sure to use passing-by-reference; failing to do so can double your memory requirements, possibly hitting the ini_set('memory_lmit', ??) Have you benchmarked this? PHP's copy-on-change philosophy means there shouldn't be much difference in memory terms -- so unless you actually expect to change the array's contents, you should pass by value. As proof, I constructed this little test: function test($arg, $base_mem) { echo Additional inside func = , memory_get_usage()-$base_mem, br /\n; } try changing this to access the array in some way such as: function test($arg, $base_mem) { foreach( $arg as $index = $value ) { } echo Additional= , memory_get_usage()-$base_mem, \n; } After array creation = 52696 Additional = 101152 Final = 117200 vs: function test($arg, $base_mem) After array creation = 52696 Additional = 53104 Final = 101696 there's the double memory usage I don't know what you guys are doing wrong but the following should be the correct behaviour: ?php function get_memory( $init=false ) { static $base = null; if( $base === null || $init ) { $base = memory_get_usage(); } return memory_get_usage() - $base; } function simple_access( $data ) { $foo = $data[100]; echo 'Memory: '.get_memory().' (simple access)'.\n; } function foreach_value_access( $data ) { foreach( $data as $value ) { $foo = $value; break; } echo 'Memory: '.get_memory().' (foreach value access)'.\n; } function foreach_key_access( $data ) { foreach( $data as $key = $value ) { $foo = $key; $foo = $value; break; } echo 'Memory: '.get_memory().' (foreach key/value access)'.\n; } function modify_single_access( $data ) { $data[100] = str_repeat( '@', 1 ); echo 'Memory: '.get_memory().' (modify single access)'.\n; } function modify_all_access( $data ) { for( $i = 0; $i 1000; $i++ ) { $data[$i] = str_repeat( '@', 1 ); } echo 'Memory: '.get_memory().' (modify all access)'.\n; } get_memory( true ); $data = array(); for( $i = 0; $i 1000; $i++ ) { $data[$i] = str_repeat( '#', 1 ); } echo 'Memory: '.get_memory().' (data initialized)'.\n; simple_access( $data ); foreach_value_access( $data ); foreach_key_access( $data ); modify_single_access( $data ); modify_all_access( $data ); ? I get the following output (PHP 5.2.11 from command-line): Memory: 10160768 (data initialized) Memory: 10161008 (simple access) Memory: 10161104 (foreach value access) Memory: 10161240 (foreach key/value access) Memory: 10267312 (modify single access) Memory: 20321576 (modify all access) I don't double up on memory consumption until I force the write onto every element... this is expected because internally every array element is individually subject to the Copy-On-Write (COW) principle since each element is internally stored as a zval just like the array itself. 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] 120 meg of json analyzed by the browser...
Rene Veerman wrote: Hi.. I've built http://mediabeez.ws/htmlMicroscope/ (lgpl), which provides a way to look at very big arrays in the browser. I'm kinda stuck at a 120 - 200Mb data-size limit, and have exhausted all my ideas on how to increase that limit further. My reasoning is that i have a gigabyte free memory on my machine, and want to use that to look at an array of at least 800mb. I know, it's a totally academic feature at the moment. But still, i would like feedback on how to increase the datasize limit to actual-free-RAM. If it's at all possible. I would greatly appreciate feedback from webbrowser developers. If you have some time and energy, please download the 1.3.0-beta on my site, and have a look to see if you can find something to improve. Use get_memory() to see just how much memory you're using. Somewhere in your script you are probably storing much more memory than you think. 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] Pointers For Newbies, Reminders For Oldies
On Thu, Jan 28, 2010 at 11:41:43AM -, Ford, Mike wrote: -Original Message- From: Rene Veerman [mailto:rene7...@gmail.com] Sent: 27 January 2010 22:46 And if your script needs to pass large ( 5Mb) arrays around to functions, be sure to use passing-by-reference; failing to do so can double your memory requirements, possibly hitting the ini_set('memory_lmit', ??) Have you benchmarked this? PHP's copy-on-change philosophy means there shouldn't be much difference in memory terms -- so unless you actually expect to change the array's contents, you should pass by value. As proof, I constructed this little test: snip All in all, there is no evidence that passing arrays to functions by value is inherently more expensive than by reference, and in fact in some cases it can be significantly cheaper. Which in turn says that you should only pass arguments by reference when you actually expect to change them, which is after all what the by-reference operator is there for in the first place! QED. Counter-intuitive benchmarks. Can we not? Benchmarking something on a given version of PHP is nice, but changes to the PHP engine occur on a relatively routine basis. Shall we benchmark each tip each time we change PHP versions, and then rework all our code to conform to the latest benchmark, depending on the version of PHP our code is running under? A better example might be the use of single, versus double quotes. Regardless of benchmarks, it's logically obvious that if the PHP engine doesn't have to evaluate the contents inside single quotes, an expression's evaluation should take less time and use fewer system resources. Naturally, the PHP engine could be tweaked to equalize evaluation between single- and double-quote expressions. But this could also change as the PHP engine is changed. To put it more simply, we can say that, depending on the version of PHP, single-quoted versus double-quoted expressions will be evaluated in equal amounts of time and using equivalent system resources. And if you prefer to double-quote everything, by all means do so. But the fact remains that the documentation for PHP says that the contents of a string delimited by single quotes will not be evaluated, whereas those within double quotes will be. What these tips are about is coding things using best practices, derived from logical examination of the way PHP is advertised to function, not transitory benchmarks. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Reports generator
On Thu, Jan 28, 2010 at 01:31:30AM -0800, Allen McCabe wrote: snip SIDE QUESTION: What do you think of my use of serialization? I don't see a need to store duplicate information in new tables, and thought serializing these one shot reports the best solution. I couldn't really find a good reason to store the serialized representation of the queries, to be honest. In fact, the only reason I would store the serialized representation of anything is as a last resort, when no other way of storing it makes sense. Going back to the methodology I covered in my previous email, I wouldn't store the results of a query in a database. If you find you simply must save the results, just jam the whole HTML page into a string and store that (unless I'm misunderstanding what you're doing). Otherwise, just generate the report in real time. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Pointers For Newbies, Reminders For Oldies
Paul M Foster wrote: On Thu, Jan 28, 2010 at 11:41:43AM -, Ford, Mike wrote: -Original Message- From: Rene Veerman [mailto:rene7...@gmail.com] Sent: 27 January 2010 22:46 And if your script needs to pass large ( 5Mb) arrays around to functions, be sure to use passing-by-reference; failing to do so can double your memory requirements, possibly hitting the ini_set('memory_lmit', ??) Have you benchmarked this? PHP's copy-on-change philosophy means there shouldn't be much difference in memory terms -- so unless you actually expect to change the array's contents, you should pass by value. As proof, I constructed this little test: snip All in all, there is no evidence that passing arrays to functions by value is inherently more expensive than by reference, and in fact in some cases it can be significantly cheaper. Which in turn says that you should only pass arguments by reference when you actually expect to change them, which is after all what the by-reference operator is there for in the first place! QED. Counter-intuitive benchmarks. Can we not? Benchmarking something on a given version of PHP is nice, but changes to the PHP engine occur on a relatively routine basis. Shall we benchmark each tip each time we change PHP versions, and then rework all our code to conform to the latest benchmark, depending on the version of PHP our code is running under? I've been working with PHP for about 9 years now... I believe Copy-On-Write was implemented at the outset of PHP 4. This isn't a feature that tends to change from one version to the next. This feature has a very very specific purpose and it's a purpose that won't be discarded anytime soon... if ever. A better example might be the use of single, versus double quotes. Regardless of benchmarks, it's logically obvious that if the PHP engine doesn't have to evaluate the contents inside single quotes, an expression's evaluation should take less time and use fewer system resources. Naturally, the PHP engine could be tweaked to equalize evaluation between single- and double-quote expressions. But this could also change as the PHP engine is changed. Single versus double isn't much of an argument... inefficient opcode generation in the past made one more lucrative than the other, but this has been pretty much eliminated in the 5 series. As a result of better opcode generation, the hit to parsing double versus single quotes should only be happening at the parse stage, not at the run stage. To put it more simply, we can say that, depending on the version of PHP, single-quoted versus double-quoted expressions will be evaluated in equal amounts of time and using equivalent system resources. And if you prefer to double-quote everything, by all means do so. But the fact remains that the documentation for PHP says that the contents of a string delimited by single quotes will not be evaluated, whereas those within double quotes will be. This is true to a point... but if we have the following: echo blah $foo bleh; And this produces opcodes: SET tvar blah CAT tvar $foo CAT tvar bleh ECHO tvar And then we have: echo 'blah'.$foo.' bleh'; And this produces opcodes: SET tvar blah CAT tvar $foo CAT tvar bleh ECHO tvar Then beyond the parse stage these are obviously identical. Thus, in my own code these days, I use whichever one makes the content easier to read. For embedding vars into regular content I use double quotes, for outputing HTML I tend to use single quotes so that I don' t need to escape the double quotes for the tag attributes. What these tips are about is coding things using best practices, derived from logical examination of the way PHP is advertised to function, not transitory benchmarks. It helps to have a keen insight into not just how to use PHP, but how PHP itself works. This is where studying history, the PHP code itself, parsers, compilers, optimizers, virtual engines, etc will aid in your understanding of the underlying architecture. Of course, many of these pursuits lie more in the field of Computer Science than in the realm code monkeying :) 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] Reports generator
Paul M Foster wrote: On Thu, Jan 28, 2010 at 01:31:30AM -0800, Allen McCabe wrote: snip SIDE QUESTION: What do you think of my use of serialization? I don't see a need to store duplicate information in new tables, and thought serializing these one shot reports the best solution. I couldn't really find a good reason to store the serialized representation of the queries, to be honest. In fact, the only reason I would store the serialized representation of anything is as a last resort, when no other way of storing it makes sense. Going back to the methodology I covered in my previous email, I wouldn't store the results of a query in a database. If you find you simply must save the results, just jam the whole HTML page into a string and store that (unless I'm misunderstanding what you're doing). Otherwise, just generate the report in real time. I disagree... storing the results of a complex query that took 5 seconds to run into a cache table that takes .01 seconds to retrieve has obvious efficiency gains. That said, the database engine may do caching for you, however if you know the query results are valid for a whole week, then again it's useful to cache it yourself. Of course, the cache could also lie on the filesystem or shared memory or whatever, but that's just implementation details :) Either way, serialized data is quick to generate, quick to unserialize, and since it's temporary you can use a less flexible storage format. 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] 120 meg of json analyzed by the browser...
On Thu, Jan 28, 2010 at 4:04 PM, Robert Cummings rob...@interjinn.com wrote: Use get_memory() to see just how much memory you're using. Somewhere in your script you are probably storing much more memory than you think. My functions do print the memory usage; I'm just wondering why the array returned is 1/5th of the desired (and allocated) size. global $hmGenKeys; $hmGenKeys = 0; global $hmGenKeysDone; $hmGenKeysDone = 0; function htmlMicroscope_generateRandomArray ($maxKeys, $maxDepth, $maxDuration=-1, $maxMem=-1) { global $hmGenKeys; global $hmGenKeysDone; $r = array(); $l1 = false; if ($maxKeys!==null) { $hmGenKeys = $maxKeys; $l1 = true; } $hmGenKeys--; if ($hmGenKeys=0) return false; if ($maxDepth=0) return false; if ($l1) { srand(htmlMicroscope_randMakeSeed()); while ($hmGenKeys 0) { $hmGenKeys--; $hmGenKeysDone++; file_put_contents('countdown.txt', 'k:'.number_format($hmGenKeysDone,0,'.',','). ' m:'.number_format(memory_get_usage(true),0,'.',',') ); if ($maxMem!=-1 memory_get_usage(true) $maxMem) return $r; if ($maxDuration!=-1 $maxDuration getDuration()) return $r; switch (rand(1,2)) { case 1 : $next = htmlMicroscope_generateRandomArray (null, $maxDepth-1, $maxDuration, $maxMem); if ($next!==false) $r += array( htmlMicroscope_randomValue(4) = $next ); break; case 2 : $r += array( htmlMicroscope_randomValue(4) = htmlMicroscope_randomValue(20) ); break; } } } else { $range = rand(0,50); for ($i=0; $i$range; $i++) { $hmGenKeys--; $hmGenKeysDone++; file_put_contents('countdown.txt', 'k:'.number_format($hmGenKeysDone,0,'.',','). ' m:'.number_format(memory_get_usage(true),0,'.',',') ); if ($maxMem!=-1 memory_get_usage(true) $maxMem) return $r; if ($maxDuration!=-1 $maxDuration getDuration()) return $r; switch (rand(1,2)) { case 1 : $next = htmlMicroscope_generateRandomArray (null, $maxDepth-1, $maxDuration, $maxMem); if ($next!==false) $r += array( htmlMicroscope_randomValue(4) = $next ); break; case 2 : $r += array( htmlMicroscope_randomValue(4) = htmlMicroscope_randomValue(20) ); break; } } } if (($hmGenKeysDone/7919)==round($hmGenKeysDone/7919)) sleep(1); return $r; } function htmlMicroscope_randomValue($maxLength) { $r = ''; switch (rand(0,9)) { case 0 : $r = rand (0,1); break; case 1 : $r = rand (0,1) / rand(1,100) / 3; break; default: switch (rand(0,1)) { case 0: $rnd = rand(1,$maxDepth); for ($i = 0; $i $rnd; $i++) { $r.= unichr(rand(0,hexdec(''))); } break; case 1: for ($i = 0; $i $maxLength; $i++) { $r.=chr(rand(ord('a'),ord('z')));; } break; } break; } //echo $r.'br/'.$maxLength.'br/'; return $r; } function htmlMicroscope_randMakeSeed() { list($usec, $sec) = explode(' ', microtime()); return (float) $sec + ((float) $usec * 10); } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: 120 meg of json analyzed by the browser...
Oh, i forgot to mention that firefox takes about a gigabyte of memory after having stalled at 200mb parsed in a 330mb document.. And despite using setTimeout(), firefox frequently freezes (for about 2 to 10 minutes), before updating the decoding-status display again. I'd really appreciate someone checking my non-eval() json parser-decoder to see if my code is at fault, or if i've triggered a firefox 'bug'. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Reports generator
On Thu, Jan 28, 2010 at 10:49:17AM -0500, Robert Cummings wrote: Paul M Foster wrote: On Thu, Jan 28, 2010 at 01:31:30AM -0800, Allen McCabe wrote: snip SIDE QUESTION: What do you think of my use of serialization? I don't see a need to store duplicate information in new tables, and thought serializing these one shot reports the best solution. I couldn't really find a good reason to store the serialized representation of the queries, to be honest. In fact, the only reason I would store the serialized representation of anything is as a last resort, when no other way of storing it makes sense. Going back to the methodology I covered in my previous email, I wouldn't store the results of a query in a database. If you find you simply must save the results, just jam the whole HTML page into a string and store that (unless I'm misunderstanding what you're doing). Otherwise, just generate the report in real time. I disagree... storing the results of a complex query that took 5 seconds to run into a cache table that takes .01 seconds to retrieve has obvious efficiency gains. That said, the database engine may do caching for you, however if you know the query results are valid for a whole week, then again it's useful to cache it yourself. Of course, the cache could also lie on the filesystem or shared memory or whatever, but that's just implementation details :) Either way, serialized data is quick to generate, quick to unserialize, and since it's temporary you can use a less flexible storage format. Perhaps, but as I said, Going back to the methodology I covered in my previous email. The optimization you're talking about is something I'd tackle at the 2.0 version, not the first crack I encouraged him to take. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: 120 meg of json analyzed by the browser...
Rene Veerman wrote: Oh, i forgot to mention that firefox takes about a gigabyte of memory after having stalled at 200mb parsed in a 330mb document.. And despite using setTimeout(), firefox frequently freezes (for about 2 to 10 minutes), before updating the decoding-status display again. I'd really appreciate someone checking my non-eval() json parser-decoder to see if my code is at fault, or if i've triggered a firefox 'bug'. in all honesty I'm kinda wondering why anybody would want to look at 120+mb of array data in a web browser - do you have any use-cases? as for the firefox side of things, it's built and designed to handle web pages, documents, extensions and streaming media - when the rest of the world is focussed on making things smaller, to optimise for making things bigger normally doesn't come in to the equation. regards though - challenges are what make us better. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Reports generator
Paul M Foster wrote: On Thu, Jan 28, 2010 at 10:49:17AM -0500, Robert Cummings wrote: Paul M Foster wrote: On Thu, Jan 28, 2010 at 01:31:30AM -0800, Allen McCabe wrote: snip SIDE QUESTION: What do you think of my use of serialization? I don't see a need to store duplicate information in new tables, and thought serializing these one shot reports the best solution. I couldn't really find a good reason to store the serialized representation of the queries, to be honest. In fact, the only reason I would store the serialized representation of anything is as a last resort, when no other way of storing it makes sense. Going back to the methodology I covered in my previous email, I wouldn't store the results of a query in a database. If you find you simply must save the results, just jam the whole HTML page into a string and store that (unless I'm misunderstanding what you're doing). Otherwise, just generate the report in real time. I disagree... storing the results of a complex query that took 5 seconds to run into a cache table that takes .01 seconds to retrieve has obvious efficiency gains. That said, the database engine may do caching for you, however if you know the query results are valid for a whole week, then again it's useful to cache it yourself. Of course, the cache could also lie on the filesystem or shared memory or whatever, but that's just implementation details :) Either way, serialized data is quick to generate, quick to unserialize, and since it's temporary you can use a less flexible storage format. Perhaps, but as I said, Going back to the methodology I covered in my previous email. The optimization you're talking about is something I'd tackle at the 2.0 version, not the first crack I encouraged him to take. I don't believe in arduous investment in early optimization but if it's low hanging fruit and you're already aware of the issue, programming it in early can save you time later. 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: 120 meg of json analyzed by the browser...
Op 1/28/10 5:03 PM, Rene Veerman schreef: Oh, i forgot to mention that firefox takes about a gigabyte of memory after having stalled at 200mb parsed in a 330mb document.. And despite using setTimeout(), firefox frequently freezes (for about 2 to 10 minutes), before updating the decoding-status display again. I'd really appreciate someone checking my non-eval() json parser-decoder to see if my code is at fault, or if i've triggered a firefox 'bug'. just guessing but I doubt you have a real issue in your parser-decoder, the memory used by firefox seems reasonable to my untrained eye - I'd guess that a factor 5 memory overhead is normal given the amount of abstraction involved in the browser doing it's thing. pretty cool what your trying to do - but, totally nuts of course :) I would think that you're only recourse really is to chunk the output of both the server and the browser so that you can, theoretically, page through the data structure in the browser ... might be totally inpractical, if not impossible. not to mention you likely to have to use file-based storage for the chunks of output on the server side to avoid running out of mem. hard problem! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: 120 meg of json analyzed by the browser...
On Thu, 2010-01-28 at 17:30 +0100, Jochem Maas wrote: Op 1/28/10 5:03 PM, Rene Veerman schreef: Oh, i forgot to mention that firefox takes about a gigabyte of memory after having stalled at 200mb parsed in a 330mb document.. And despite using setTimeout(), firefox frequently freezes (for about 2 to 10 minutes), before updating the decoding-status display again. I'd really appreciate someone checking my non-eval() json parser-decoder to see if my code is at fault, or if i've triggered a firefox 'bug'. just guessing but I doubt you have a real issue in your parser-decoder, the memory used by firefox seems reasonable to my untrained eye - I'd guess that a factor 5 memory overhead is normal given the amount of abstraction involved in the browser doing it's thing. pretty cool what your trying to do - but, totally nuts of course :) I would think that you're only recourse really is to chunk the output of both the server and the browser so that you can, theoretically, page through the data structure in the browser ... might be totally inpractical, if not impossible. not to mention you likely to have to use file-based storage for the chunks of output on the server side to avoid running out of mem. hard problem! You could page through the data and make it look like it's happening all in the browser with a bit of clever ajax Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Re: 120 meg of json analyzed by the browser...
At 200Mb/330Mb parsing, i have released 200Mb of html comment nodes, and should have accumulated only 200Mb of javascript array/object. it's _just_ the data, no HTML has been generated yet. I accept a 5x overhead for turning it into HTML, but wonder why firefox a) stops updating the screen despite regular .setTimeout() pauses b) accumulates 1 gigabyte of memory after only 200Mb has been processed. And i dont think paging is possible, as i want to display things like the path (of parent nodes) and sibling list for each sub-array in the data. On Thu, Jan 28, 2010 at 5:30 PM, Jochem Maas joc...@iamjochem.com wrote: just guessing but I doubt you have a real issue in your parser-decoder, the memory used by firefox seems reasonable to my untrained eye - I'd guess that a factor 5 memory overhead is normal given the amount of abstraction involved in the browser doing it's thing. pretty cool what your trying to do - but, totally nuts of course :) I would think that you're only recourse really is to chunk the output of both the server and the browser so that you can, theoretically, page through the data structure in the browser ... might be totally inpractical, if not impossible. not to mention you likely to have to use file-based storage for the chunks of output on the server side to avoid running out of mem. hard problem! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: 120 meg of json analyzed by the browser...
On Thu, Jan 28, 2010 at 5:32 PM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: You could page through the data and make it look like it's happening all in the browser with a bit of clever ajax Ok, good point. Maybe JSON-transport javascript parsing just has it's limit at just over 100 meg. Accepting the fact that it would make the serverside code much more complex and thus harder to port, the data would imo need to be shoved into a db, because i doubt the flat-file storage of $_SESSION would work well. Anyone know of a piece of code that can pump a 1000-level deep array of 2 gigabyte into a mysql db and retrieve subtrees (startID, depth, filters?) efficiently?
Re: [PHP] Replacing accented characters?
At 9:28 AM -0500 1/28/10, Robert Cummings wrote: tedd wrote: At 12:17 PM +0100 1/28/10, Marcus Gnaß wrote: On 28.01.2010 03:40, Paul M Foster wrote: On Wed, Jan 27, 2010 at 04:55:46PM -0600, Skip Evans wrote: Hey all, I'm looking for recommendations on how to replace accented characters, like e and u with those two little dots above them, with the regular e and u characters. FWIW, those two dots are called an umlaut. Paul FWIW, the whole letters ÄäÖöÜü are called Umlaute (umlauts). The two dots above *these* letters are Umlautzeichen (umlaut marks). But two dots above an e or i are called Trema (diacritic mark). Marcus On what other list could we learn that? A linguistics list I'd wager. :B Cheers, Rob. And let's not forget the Trema list. :-) My point was more to the theme that we are an eclectic group of people with a wide range of knowledge and skills. Individually we may have trouble finding our ass, but together we can find the answer to many things. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Creating an Entire .html page with PHP
On Thu, Jan 28, 2010 at 12:31 AM, clanc...@cybec.com.au wrote: On Wed, 27 Jan 2010 10:21:00 -0800, deal...@gmail.com (dealtek) wrote: Opening tables, etc, wrongly generally messes the page up completely, but forgetting to close them again often has no affect no visible effect at all -- until you make some innocent change and everything goes haywire! whenever i write an opening tag, i immediately write the closing tag next, then cursor back to fill it in. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Creating an Entire .html page with PHP
On Thu, 28 Jan 2010 21:10:42 +0100, rene7...@gmail.com (Rene Veerman) wrote: On Thu, Jan 28, 2010 at 12:31 AM, clanc...@cybec.com.au wrote: On Wed, 27 Jan 2010 10:21:00 -0800, deal...@gmail.com (dealtek) wrote: Opening tables, etc, wrongly generally messes the page up completely, but forgetting to close them again often has no affect no visible effect at all -- until you make some innocent change and everything goes haywire! whenever i write an opening tag, i immediately write the closing tag next, then cursor back to fill it in. Not so easy when you are using PHP to generate a complex layout! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Replacing accented characters?
On Thu, Jan 28, 2010 at 02:38:52PM -0500, tedd wrote: snip My point was more to the theme that we are an eclectic group of people with a wide range of knowledge and skills. Individually we may have trouble finding our ass, but together we can find the answer to many things. I just got this image of all of us at a table at the local Chili's twirling around in place like dogs, trying to find our asses. giggle Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Creating an Entire .html page with PHP
On Fri, Jan 29, 2010 at 08:17:34AM +1100, clanc...@cybec.com.au wrote: On Thu, 28 Jan 2010 21:10:42 +0100, rene7...@gmail.com (Rene Veerman) wrote: On Thu, Jan 28, 2010 at 12:31 AM, clanc...@cybec.com.au wrote: On Wed, 27 Jan 2010 10:21:00 -0800, deal...@gmail.com (dealtek) wrote: Opening tables, etc, wrongly generally messes the page up completely, but forgetting to close them again often has no affect no visible effect at all -- until you make some innocent change and everything goes haywire! whenever i write an opening tag, i immediately write the closing tag next, then cursor back to fill it in. Not so easy when you are using PHP to generate a complex layout! Use heredocs to do it. Then you can generate the layout in PHP and still do what deal...@gmail.com said. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Replacing accented characters?
Paul M Foster wrote: On Thu, Jan 28, 2010 at 02:38:52PM -0500, tedd wrote: snip My point was more to the theme that we are an eclectic group of people with a wide range of knowledge and skills. Individually we may have trouble finding our ass, but together we can find the answer to many things. I just got this image of all of us at a table at the local Chili's twirling around in place like dogs, trying to find our asses. giggle I wish you'd stop grabbing ming!! :B 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] Replacing accented characters?
Robert Cummings wrote: Paul M Foster wrote: On Thu, Jan 28, 2010 at 02:38:52PM -0500, tedd wrote: snip My point was more to the theme that we are an eclectic group of people with a wide range of knowledge and skills. Individually we may have trouble finding our ass, but together we can find the answer to many things. I just got this image of all of us at a table at the local Chili's twirling around in place like dogs, trying to find our asses. giggle I wish you'd stop grabbing ming!! :B Mine even... doh! -- 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] Creating an Entire .html page with PHP
On Thu, 2010-01-28 at 16:23 -0500, Paul M Foster wrote: On Fri, Jan 29, 2010 at 08:17:34AM +1100, clanc...@cybec.com.au wrote: On Thu, 28 Jan 2010 21:10:42 +0100, rene7...@gmail.com (Rene Veerman) wrote: On Thu, Jan 28, 2010 at 12:31 AM, clanc...@cybec.com.au wrote: On Wed, 27 Jan 2010 10:21:00 -0800, deal...@gmail.com (dealtek) wrote: Opening tables, etc, wrongly generally messes the page up completely, but forgetting to close them again often has no affect no visible effect at all -- until you make some innocent change and everything goes haywire! whenever i write an opening tag, i immediately write the closing tag next, then cursor back to fill it in. Not so easy when you are using PHP to generate a complex layout! Use heredocs to do it. Then you can generate the layout in PHP and still do what deal...@gmail.com said. Paul -- Paul M. Foster Not really always. I often use fairly complex code to handle output of content into tables where the number of columns varies on the content. Cases like this are not something you can tackle with heredoc or nowdoc, and don't allow you to just create the opening and closing tags and build the PHP around them. Sometimes you just have to use your smarts a bit :p Of course, I do find that proper code indentation is of the absolute importance, and running the output through a validator helps! Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Creating an Entire .html page with PHP
clanc...@cybec.com.au wrote: On Thu, 28 Jan 2010 21:10:42 +0100, rene7...@gmail.com (Rene Veerman) wrote: On Thu, Jan 28, 2010 at 12:31 AM, clanc...@cybec.com.au wrote: On Wed, 27 Jan 2010 10:21:00 -0800, deal...@gmail.com (dealtek) wrote: Opening tables, etc, wrongly generally messes the page up completely, but forgetting to close them again often has no affect no visible effect at all -- until you make some innocent change and everything goes haywire! whenever i write an opening tag, i immediately write the closing tag next, then cursor back to fill it in. Not so easy when you are using PHP to generate a complex layout! Use DOMDocument. Then you don't have to worry about closing the tags ;) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Creating an Entire .html page with PHP
On Thu, Jan 28, 2010 at 10:17 PM, clanc...@cybec.com.au wrote: On Thu, 28 Jan 2010 21:10:42 +0100, rene7...@gmail.com (Rene Veerman) wrote: On Thu, Jan 28, 2010 at 12:31 AM, clanc...@cybec.com.au wrote: On Wed, 27 Jan 2010 10:21:00 -0800, deal...@gmail.com (dealtek) wrote: Opening tables, etc, wrongly generally messes the page up completely, but forgetting to close them again often has no affect no visible effect at all -- until you make some innocent change and everything goes haywire! whenever i write an opening tag, i immediately write the closing tag next, then cursor back to fill it in. Not so easy when you are using PHP to generate a complex layout! eh, why not? complex layouts can and should be split up into functions, which can adhere to the same principle.. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Good source for sample data?
Hey all - I need a few million sample contact records - name, company, address, email, web, phone, fax. ZIP codes and area codes and street addresses should be correct and properly formatted, but preferably not real people or companies or email addresses. But they'd work if you did address validation or mapping. Anyone have a suggestion? - Brian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Good source for sample data?
Brian Dunning wrote: Hey all - I need a few million sample contact records - name, company, address, email, web, phone, fax. ZIP codes and area codes and street addresses should be correct and properly formatted, but preferably not real people or companies or email addresses. But they'd work if you did address validation or mapping. Anyone have a suggestion? - Brian It should be easy to code a routine to generate random data. Maybe 20 - 30 lines of code. Obviously you may have a name like Dgidfgq Xcvbop and company Wsdkn, but it shouldn't matter if testing is your purpose. -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Good source for sample data?
Brian Dunning wrote: Hey all - I need a few million sample contact records - name, company, address, email, web, phone, fax. ZIP codes and area codes and street addresses should be correct and properly formatted, but preferably not real people or companies or email addresses. But they'd work if you did address validation or mapping. Anyone have a suggestion? - Brian get the data from a whats near X API and obscure the personally identifiable data with dummy values. ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Good source for sample data?
I remembered a coworker found an online resource that generated sample data for you. I hit google and I think I found it: http://www.generatedata.com/ I I found it on a list of resources for data generation: http://www.webresourcesdepot.com/test-sample-data-generators/ I've never used any of these, but once again.. Google is your friend. -TG - Original Message - From: Brian Dunning br...@briandunning.com To: php-general@lists.php.net, my...@lists.mysql.com Date: Thu, 28 Jan 2010 15:52:41 -0800 Subject: [PHP] Good source for sample data? Hey all - I need a few million sample contact records - name, company, address, email, web, phone, fax. ZIP codes and area codes and street addresses should be correct and properly formatted, but preferably not real people or companies or email addresses. But they'd work if you did address validation or mapping. Anyone have a suggestion? - Brian -- 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] Good source for sample data?
Fakenamegenerator.com is pretty good for these kinds of records, alot of variety and can change order/formating for them but they do limit free orders to 50k records. http://www.fakenamegenerator.com/order.php On Thu, Jan 28, 2010 at 8:06 PM, TG tg-...@gryffyndevelopment.com wrote: I remembered a coworker found an online resource that generated sample data for you. I hit google and I think I found it: http://www.generatedata.com/ I I found it on a list of resources for data generation: http://www.webresourcesdepot.com/test-sample-data-generators/ I've never used any of these, but once again.. Google is your friend. -TG - Original Message - From: Brian Dunning br...@briandunning.com To: php-general@lists.php.net, my...@lists.mysql.com Date: Thu, 28 Jan 2010 15:52:41 -0800 Subject: [PHP] Good source for sample data? Hey all - I need a few million sample contact records - name, company, address, email, web, phone, fax. ZIP codes and area codes and street addresses should be correct and properly formatted, but preferably not real people or companies or email addresses. But they'd work if you did address validation or mapping. Anyone have a suggestion? - Brian -- 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] exception throw from __autoload could not be catched on php 5.3.1
Hi php-dev pros, I got an issue about catching exception throw from __autoload on php 5.3.1. The manual state that exception throw from __autoload could be catched with try.. catch statement same as the normal flow. But I'can archive that even I have copied the same sample code from the manual. Here are the code segment. [[[ function __autoload($name) { echo Want to load $name.\n; throw new Exception(Unable to load $name.); } try { $obj = new NonLoadableClass(); } catch (Exception $e) { echo $e-getMessage(), \n; } ]]] Are there anyone experienced this or not ? Thanks in advance ! Regards, Eric,
Re: [PHP] exception throw from __autoload could not be catched on php 5.3.1
On Fri, 2010-01-29 at 13:02 +0800, Eric Lee wrote: Hi php-dev pros, I got an issue about catching exception throw from __autoload on php 5.3.1. The manual state that exception throw from __autoload could be catched with try.. catch statement same as the normal flow. But I'can archive that even I have copied the same sample code from the manual. Here are the code segment. [[[ function __autoload($name) { echo Want to load $name.\n; throw new Exception(Unable to load $name.); } try { $obj = new NonLoadableClass(); } catch (Exception $e) { echo $e-getMessage(), \n; } ]]] Are there anyone experienced this or not ? Thanks in advance ! Regards, Eric, What version of PHP are you using? The example will only work on PHP version 5.3.0 and above Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] exception throw from __autoload could not be catched on php 5.3.1
On Fri, 2010-01-29 at 13:02 +0800, Eric Lee wrote: Hi php-dev pros, I got an issue about catching exception throw from __autoload on php 5.3.1. The manual state that exception throw from __autoload could be catched with try.. catch statement same as the normal flow. But I'can archive that even I have copied the same sample code from the manual. Here are the code segment. [[[ function __autoload($name) { echo Want to load $name.\n; throw new Exception(Unable to load $name.); } try { $obj = new NonLoadableClass(); } catch (Exception $e) { echo $e-getMessage(), \n; } ]]] Are there anyone experienced this or not ? Thanks in advance ! Regards, Eric, Sorry, ignore that, I see you're running 5.3.1, which should be fine for running the example. I do notice that you've got [[[ and ]]] in-place of ?php and ?, was that intentional? Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] exception throw from __autoload could not be catched on php 5.3.1
于 2010-1-29 13:19, Ashley Sheridan 写道: On Fri, 2010-01-29 at 13:02 +0800, Eric Lee wrote: Hi php-dev pros, I got an issue about catching exception throw from __autoload on php 5.3.1. The manual state that exception throw from __autoload could be catched with try.. catch statement same as the normal flow. But I'can archive that even I have copied the same sample code from the manual. Here are the code segment. [[[ function __autoload($name) { echo Want to load $name.\n; throw new Exception(Unable to load $name.); } try { $obj = new NonLoadableClass(); } catch (Exception $e) { echo $e-getMessage(), \n; } ]]] Are there anyone experienced this or not ? Thanks in advance ! Regards, Eric, Sorry, ignore that, I see you're running 5.3.1, which should be fine for running the example. I do notice that you've got [[[ and ]]] in-place of ?php and ?, was that intentional? Thanks, Ash http://www.ashleysheridan.co.uk Do you have any other autoload implamentaions? try testing that code segment in a single php file and dump phpinfo() to make sure you are on php 5.3.1 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] exception throw from __autoload could not be catched on php 5.3.1
On Fri, Jan 29, 2010 at 1:19 PM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: On Fri, 2010-01-29 at 13:02 +0800, Eric Lee wrote: Hi php-dev pros, I got an issue about catching exception throw from __autoload on php 5.3.1. The manual state that exception throw from __autoload could be catched with try.. catch statement same as the normal flow. But I'can archive that even I have copied the same sample code from the manual. Here are the code segment. [[[ function __autoload($name) { echo Want to load $name.\n; throw new Exception(Unable to load $name.); } try { $obj = new NonLoadableClass(); } catch (Exception $e) { echo $e-getMessage(), \n; } ]]] Are there anyone experienced this or not ? Thanks in advance ! Regards, Eric, Sorry, ignore that, I see you're running 5.3.1, which should be fine for running the example. I do notice that you've got [[[ and ]]] in-place of ?php and ?, was that intentional? Sorry for that ! I'am too lazy !! And that's just for easy looking the code. I actually use this, ?php function __autoload($name) { echo Want to load $name.\n; throw new Exception(Unable to load $name.); } try { $obj = new NonLoadableClass(); } catch (Exception $e) { echo $e-getMessage(), \n; } ? Regards, Eric, Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] exception throw from __autoload could not be catched on php 5.3.1
Hi all and thanks for Ryan, I apologize ! ! I have missed out the small class_exists call before it. Thanks. Regards, Eric, 2010/1/29 Ryan ryansu...@gmail.com 于 2010-1-29 13:19, Ashley Sheridan 写道: On Fri, 2010-01-29 at 13:02 +0800, Eric Lee wrote: Hi php-dev pros, I got an issue about catching exception throw from __autoload on php 5.3.1. The manual state that exception throw from __autoload could be catched with try.. catch statement same as the normal flow. But I'can archive that even I have copied the same sample code from the manual. Here are the code segment. [[[ function __autoload($name) { echo Want to load $name.\n; throw new Exception(Unable to load $name.); } try { $obj = new NonLoadableClass(); } catch (Exception $e) { echo $e-getMessage(), \n; } ]]] Are there anyone experienced this or not ? Thanks in advance ! Regards, Eric, Sorry, ignore that, I see you're running 5.3.1, which should be fine for running the example. I do notice that you've got [[[ and ]]] in-place of ?php and ?, was that intentional? Thanks, Ash http://www.ashleysheridan.co.uk Do you have any other autoload implamentaions? try testing that code segment in a single php file and dump phpinfo() to make sure you are on php 5.3.1