php-general Digest 23 Jul 2009 07:54:18 -0000 Issue 6245
php-general Digest 23 Jul 2009 07:54:18 - Issue 6245 Topics (messages 295708 through 295731): Re: Client Side PHP 295708 by: Lenin 295710 by: Eddie Drapkin unsetting a referenced parameter in a function 295709 by: Tom Worster 295719 by: Shawn McKenzie 295723 by: Tom Worster 295724 by: Martin Scotta Re: Session Confusion. 295711 by: Yuri Yarlei newbie question - php parsing 295712 by: Sebastiano Pomata 295714 by: João Cândido de Souza Neto 295715 by: Shane Hill 295716 by: Lenin 295717 by: Martin Scotta 295720 by: Shawn McKenzie Re: putenv usage 295713 by: Yuri Yarlei Calculating number of checkers (draughts) possible positions 295718 by: ×× ××× ×× ×× Re: Replace in a string with regex 295721 by: Ford, Mike 295722 by: rszeus help with stream filter 295725 by: °×ºÆƽ How to build an FF extension 295726 by: Javed Khan 295727 by: Paul M Foster 295731 by: Ashley Sheridan Mediawiki's url confusion 295728 by: µËÐòÀÖ 295730 by: Paul M Foster Re: newbie - Is there a calendar module for date entry? 295729 by: phphelp -- kbk Administrivia: To subscribe to the digest, e-mail: php-general-digest-subscr...@lists.php.net To unsubscribe from the digest, e-mail: php-general-digest-unsubscr...@lists.php.net To post to the list, e-mail: php-gene...@lists.php.net -- ---BeginMessage--- On Thu, Jul 23, 2009 at 1:06 AM, Bastien Koert phps...@gmail.com wrote: On Wed, Jul 22, 2009 at 1:56 PM, Javed Khaniankha...@yahoo.com wrote: I need help on my project I want to have my browser do compling of PHP scripts. Can someone please send me some concepts and if possible codes to do this. I know this aspect will pose great security threat to the server and client but I will still love any help with this. Thanks, J. K PHP is a server side language. If you want to have php as an executable on the client, you could look at www.roadsend.com for the compiler. Otherwise, you could create a dll on windows for for execution in IE or as jim mentioned, write an extension for FF Sorry to Bastien and posting to the list again: @Javed Khan: If you just want to have php functions in client side JS then visit www.phpjs.org Did you try any good php IDE? like NetBeans 7.0 or Zend Studio or did you try Dreamweaver with site defined? ---End Message--- ---BeginMessage--- On Wed, Jul 22, 2009 at 4:03 PM, Leninle...@phpxperts.net wrote: www.phpjs.org That's hilarious! Thanks for that laugh =) ---End Message--- ---BeginMessage--- though the manual is perfectly clear that this should be expected, i was a bit surprised that the result of the following is 42 ?php function foo($a) { $a = 42; unset($a); $a = 'meaning'; } foo($a); print($a\n); ? normally i would expect unset() to free some memory. but in this example it doesn't and has a different behavior: it releases foo's reference to the global $a, allowing the next line to define a local $a. i think i'd have preferred compile error. ---End Message--- ---BeginMessage--- Tom Worster wrote: though the manual is perfectly clear that this should be expected, i was a bit surprised that the result of the following is 42 ?php function foo($a) { $a = 42; unset($a); $a = 'meaning'; } foo($a); print($a\n); ? normally i would expect unset() to free some memory. but in this example it doesn't and has a different behavior: it releases foo's reference to the global $a, allowing the next line to define a local $a. i think i'd have preferred compile error. Well, you unset the reference and then you assigned 'meaning' to a local function variable $a. Why would you get a compile error? -- Thanks! -Shawn http://www.spidean.com ---End Message--- ---BeginMessage--- On 7/22/09 6:09 PM, Shawn McKenzie nos...@mckenzies.net wrote: Tom Worster wrote: though the manual is perfectly clear that this should be expected, i was a bit surprised that the result of the following is 42 ?php function foo($a) { $a = 42; unset($a); $a = 'meaning'; } foo($a); print($a\n); ? normally i would expect unset() to free some memory. but in this example it doesn't and has a different behavior: it releases foo's reference to the global $a, allowing the next line to define a local $a. i think i'd have preferred compile error. Well, you unset the reference and then you assigned 'meaning' to a local function variable $a. Why would you get a compile error? when you state it in those terms (which are clearly correct) i wouldn't. but if the way i think is unset() destroys the specified variables (as the manual puts it) then i expect that the specified variable would be destroyed, not the reference. so, as i said, i was a bit surprised when the
Re: [PHP] How to build an FF extension
On Wed, 2009-07-22 at 23:49 -0400, Paul M Foster wrote: On Wed, Jul 22, 2009 at 08:31:10PM -0700, Javed Khan wrote: How to build an FF extension and how to install it. I'm using Fedora 10 operating system. Can someone please provide me with the steps Thanks J.K Let me substitute for Dan here. You're asking this on a PHP list, which isn't the appropriate venue for such a question. Firefox/Mozilla lists would be a better place to ask. Paul -- Paul M. Foster I'm not sure those lists could help him either, as the abbreviation for Firefox is Fx, not FF. Thanks Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: newbie question - php parsing
João Cândido de Souza Neto wrote: You made a mistake in your code: ?php the_title(); ? must be: ?php echo the_title(); ? Not necessarily: what if you have function the_title() { echo Title; } for example... In response to Sebastiano: There would be not much point in using something like PHP if it ignored the if statements in the code! What effectively happens in a PHP source file is that all the bits outside of the ?php ? tags are treated like an echo statement (except that it handles quotes and stuff nicely) Your original code: ?php if (the_title('','',FALSE) != 'Home') { ? h2 class=entry-header?php the_title(); ?/h2 ?php } ? can be read like: ?php if (the_title('','',FALSE) != 'Home') { echo 'h2 class=entry-header'; the_title(); echo '/h2'; } ? You might even find a small (but probably really, really, really small) performance improvement if you wrote it that way, especially if it was in some kind of loop. Note that I prefer to keep HTML separate from PHP as much as possible because it helps me to read it and helps my editor check my syntax and HTML structure better... -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: newbie question - php parsing
Thanks, it's now much more clear. I thought that html parts outside php tags were just dumped to output, no matter of if-else statements and other conditions. I was *definitely* wrong 2009/7/23 Peter Ford p...@justcroft.com: In response to Sebastiano: There would be not much point in using something like PHP if it ignored the if statements in the code! What effectively happens in a PHP source file is that all the bits outside of the ?php ? tags are treated like an echo statement (except that it handles quotes and stuff nicely) Your original code: ?php if (the_title('','',FALSE) != 'Home') { ? h2 class=entry-header?php the_title(); ?/h2 ?php } ? can be read like: ?php if (the_title('','',FALSE) != 'Home') { echo 'h2 class=entry-header'; the_title(); echo '/h2'; } ? You might even find a small (but probably really, really, really small) performance improvement if you wrote it that way, especially if it was in some kind of loop. Note that I prefer to keep HTML separate from PHP as much as possible because it helps me to read it and helps my editor check my syntax and HTML structure better... -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Structure of PHP files
Hi, It isn't really a programming question, but rather a structural. Let's suppose I have a PHP page, which is built by other PHP files' includes. Which is the better approach: in a switch-like statement I include the required PHP files, which contain all the functions, and the HTML code to provide the functionality, or create a base PHP file which contains all the funcionality, and the PHP files only contain calls for these functions, and the HTML code? I think the previous method gives more control and it is more repairable, but the later method gives more modularity. With your experiences, what method gives the better overall usability? Thanks, SanTa
Re: [PHP] Structure of PHP files
2009/7/23 Sándor Tamás (HostWare Kft.) sandorta...@hostware.hu Hi, It isn't really a programming question, but rather a structural. Let's suppose I have a PHP page, which is built by other PHP files' includes. Which is the better approach: in a switch-like statement I include the required PHP files, which contain all the functions, and the HTML code to provide the functionality, or create a base PHP file which contains all the funcionality, and the PHP files only contain calls for these functions, and the HTML code? I think the previous method gives more control and it is more repairable, but the later method gives more modularity. With your experiences, what method gives the better overall usability? Thanks, SanTa As far as i experienced, the second method brings problems about the REQUIRE. If you do put classes and functions directly in that base PHP file, it will looks fat , and you need a lot of copy/pastes. If you just put a lot of requires in that base PHP file, you may pay attention about the PATH. Usage of __FILE__ or __autoload may bring confusions. Hoping for the coming of the concept of PACKAGE. Seems that NAMESPACE will be introduced in PHP6. Dengxule 09/07/23
RE: [PHP] Structure of PHP files
-Original Message- From: Dengxule [mailto:dengx...@gmail.com] Sent: 23 July 2009 10:53 Hoping for the coming of the concept of PACKAGE. Seems that NAMESPACE will be introduced in PHP6. Already present in 5.3, actually. 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] Mediawiki's url confusion
-Original Message- From: Paul M Foster [mailto:pa...@quillandmouse.com] Sent: 23 July 2009 06:13 On Thu, Jul 23, 2009 at 11:57:51AM +0800, ?? wrote: But I cannot help myself with the url pattern : /somepath_to_mediawiki/index.php/pagetitle. How can this kind of url be parsed to the file index.php and the pagetitle be parsed as params? Why the web server not go straight into path index.php/ and look for the file named pagetitle ? This type of thing is common for sites using the MVC or Model-View-Controller paradigm. The index.php file is what's called a front controller. A front controller is usually the entrance to all the other pages of a site. URLs like this often take advantage of an Apache feature called mod_rewrite, which tells Apache how to handle URLs which look like this. Or by the pathinfo mechanism, which I believe is also supported by other Web servers, and can work just as well, if it satisfies your requirements, without all the complications of mod_rewrite. 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] How to build an FF extension
Go to the ff site and read the docs bastien On Wednesday, July 22, 2009, Javed Khan iankha...@yahoo.com wrote: How to build an FF extension and how to install it. I'm using Fedora 10 operating system. Can someone please provide me with the steps Thanks J.K -- Bastien Cat, the other other white meat -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: unsetting a referenced parameter in a function
Tom Worster wrote: On 7/22/09 6:09 PM, Shawn McKenzie nos...@mckenzies.net wrote: Tom Worster wrote: though the manual is perfectly clear that this should be expected, i was a bit surprised that the result of the following is 42 ?php function foo($a) { $a = 42; unset($a); $a = 'meaning'; } foo($a); print($a\n); ? normally i would expect unset() to free some memory. but in this example it doesn't and has a different behavior: it releases foo's reference to the global $a, allowing the next line to define a local $a. i think i'd have preferred compile error. Well, you unset the reference and then you assigned 'meaning' to a local function variable $a. Why would you get a compile error? when you state it in those terms (which are clearly correct) i wouldn't. but if the way i think is unset() destroys the specified variables (as the manual puts it) then i expect that the specified variable would be destroyed, not the reference. so, as i said, i was a bit surprised when the variable wasn't destroyed. once i understood what was happening, i thought it a bit confusing to have such scope-dependent differences in behavior of a language element. It might be easier to understand if you don't use the same var names: function foo($arg) { $arg = 42; unset($arg); $arg = 'meaning'; } $a = 0; foo($a); print($a\n); -- 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] Structure of PHP files
When I first started programming in PHP I used the second method you mentioned. I had a single file I called utils.php and it contained all the functions I could possibly need throughout my site. Unfortunately, this file grew to be over 10,000 lines and most of the time I only needed a couple of functions for each script I loaded. I have now abandoned that method and use a more modular approach. I have a lib folder that contains much smaller and specialized scripts (mainly classes). Now I only include what I need. I found it much easier to maintain than having a single file. Take care, Floyd On Jul 23, 2009, at 5:36 AM, Sándor Tamás (HostWare Kft.) wrote: Hi, It isn't really a programming question, but rather a structural. Let's suppose I have a PHP page, which is built by other PHP files' includes. Which is the better approach: in a switch-like statement I include the required PHP files, which contain all the functions, and the HTML code to provide the functionality, or create a base PHP file which contains all the funcionality, and the PHP files only contain calls for these functions, and the HTML code? I think the previous method gives more control and it is more repairable, but the later method gives more modularity. With your experiences, what method gives the better overall usability? Thanks, SanTa -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] EXEC and SYSTEM delay
Well if the server your running on is linux based (and I haven't tried this) you could try adding a nohup and background the task for example rather than doing: system('updatedb'); try system('nohup updatedb '); It should background the task and let it continue running even when the php script finishes it's execution. Like I said I haven't tested it. As a side note I used 'updatedb' in the example because it was the longest running task I could think of off the top of my head and requires root priveledges... You really shouldn't run your scripts as root. *A public server announcement* Alberto García Gómez wrote: Fellows: I'm experimenting problems with a call that I made to exec or system. The problem is that the script await for the function finish and that take's a lot of time. I need a way to use those functions in order to continue without await for it. Saludos Fraternales _ Atte. Alberto García Gómez M:.M:. Administrador de Redes/Webmaster IPI Carlos Marx, Matanzas. Cuba. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Structure of PHP files
Floyd Resler wrote: When I first started programming in PHP I used the second method you mentioned. I had a single file I called utils.php and it contained all the functions I could possibly need throughout my site. Unfortunately, this file grew to be over 10,000 lines and most of the time I only needed a couple of functions for each script I loaded. I have now abandoned that method and use a more modular approach. I have a lib folder that contains much smaller and specialized scripts (mainly classes). Now I only include what I need. I found it much easier to maintain than having a single file. Not that I disagree with your methodology at this time, but you could have just made that single big file, include all those little files and still had a single load statement in each of your consumer source files. With compile caches the burden of loading all that code at startup is rather negligible :) 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: unsetting a referenced parameter in a function
I think he is confusing the unset semantic. Unset just destroy a variable, but not the content of it. Take a look at the output of this simple script: function avoid_global_scope() { $a = 'foo'; var_dump( get_defined_vars() ); $b = $a; var_dump( get_defined_vars() ); unset( $a ); var_dump( get_defined_vars() ); unset( $b ); } avoid_global_scope(); This is the output in my apache2 / php 5.2.6... but yours MUST be the same array(1) { [a]= string(3) foo } array(2) { [a]= string(3) foo [b]= string(3) foo } array(1) { [b]= string(3) foo } Note in the second array both variables was converted to references. But in the third b is just a common variable. This behaviour is cause by how PHP handles the references? 1) $a = 'foo'; Here we have an string 'foo' and a variable a which points to the string. 2) $b = $a; Now we have anothe variable b which refers to _contents_ of variable a Variable a is converted to a reference to it contents 3) unset( $a ); When a is destroyed only b refers to 'foo', PHP handles b as a common var 3) unset( $b ); When b is destroyed PHP notes that no one is referencing 'foo'... so, it's removed too. Remember... unset destroy variables, not it's content. class Foo { public static $last; function __construct() { self::$last = $this; } } $a = new Foo; $a = null; unset( $a ); var_dump( Foo::$last instanceof Foo ); # bool(true) On Thu, Jul 23, 2009 at 9:35 AM, Shawn McKenzie nos...@mckenzies.netwrote: Tom Worster wrote: On 7/22/09 6:09 PM, Shawn McKenzie nos...@mckenzies.net wrote: Tom Worster wrote: though the manual is perfectly clear that this should be expected, i was a bit surprised that the result of the following is 42 ?php function foo($a) { $a = 42; unset($a); $a = 'meaning'; } foo($a); print($a\n); ? normally i would expect unset() to free some memory. but in this example it doesn't and has a different behavior: it releases foo's reference to the global $a, allowing the next line to define a local $a. i think i'd have preferred compile error. Well, you unset the reference and then you assigned 'meaning' to a local function variable $a. Why would you get a compile error? when you state it in those terms (which are clearly correct) i wouldn't. but if the way i think is unset() destroys the specified variables (as the manual puts it) then i expect that the specified variable would be destroyed, not the reference. so, as i said, i was a bit surprised when the variable wasn't destroyed. once i understood what was happening, i thought it a bit confusing to have such scope-dependent differences in behavior of a language element. It might be easier to understand if you don't use the same var names: function foo($arg) { $arg = 42; unset($arg); $arg = 'meaning'; } $a = 0; foo($a); print($a\n); -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Martin Scotta
Re: [PHP] Structure of PHP files
'Tis true. I just find dealing with the smaller files much easier. At the time I was using Komodo IDE and it would get very sluggish with the larger files. Take care, Floyd On Jul 23, 2009, at 9:34 AM, Robert Cummings wrote: Floyd Resler wrote: When I first started programming in PHP I used the second method you mentioned. I had a single file I called utils.php and it contained all the functions I could possibly need throughout my site. Unfortunately, this file grew to be over 10,000 lines and most of the time I only needed a couple of functions for each script I loaded. I have now abandoned that method and use a more modular approach. I have a lib folder that contains much smaller and specialized scripts (mainly classes). Now I only include what I need. I found it much easier to maintain than having a single file. Not that I disagree with your methodology at this time, but you could have just made that single big file, include all those little files and still had a single load statement in each of your consumer source files. With compile caches the burden of loading all that code at startup is rather negligible :) 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] How to build an FF extension
2009/7/23 Ashley Sheridan a...@ashleysheridan.co.uk On Wed, 2009-07-22 at 23:49 -0400, Paul M Foster wrote: On Wed, Jul 22, 2009 at 08:31:10PM -0700, Javed Khan wrote: How to build an FF extension and how to install it. I'm using Fedora 10 operating system. Can someone please provide me with the steps Thanks J.K Let me substitute for Dan here. You're asking this on a PHP list, which isn't the appropriate venue for such a question. Firefox/Mozilla lists would be a better place to ask. Paul -- Paul M. Foster I'm not sure those lists could help him either, as the abbreviation for Firefox is Fx, not FF. Thanks Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Only officially: http://en.wikipedia.org/wiki/FFhttp://en.wikipedia.org/wiki/FF -- Luke Slater :O)
Re: [PHP] How to build an FF extension
On Thu, 2009-07-23 at 14:39 +0100, Luke wrote: 2009/7/23 Ashley Sheridan a...@ashleysheridan.co.uk On Wed, 2009-07-22 at 23:49 -0400, Paul M Foster wrote: On Wed, Jul 22, 2009 at 08:31:10PM -0700, Javed Khan wrote: How to build an FF extension and how to install it. I'm using Fedora 10 operating system. Can someone please provide me with the steps Thanks J.K Let me substitute for Dan here. You're asking this on a PHP list, which isn't the appropriate venue for such a question. Firefox/Mozilla lists would be a better place to ask. Paul -- Paul M. Foster I'm not sure those lists could help him either, as the abbreviation for Firefox is Fx, not FF. Thanks Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Only officially: http://en.wikipedia.org/wiki/FFhttp://en.wikipedia.org/wiki/FF Wikipedia can hardly be accounted an official source of anything, especially considering how it gets the content! If you want official, then http://www.mozilla.com/en-US/firefox/releases/1.5.html is a good link. Thanks Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Undefined Index ...confusion
I keep getting this error while trying to use the field 'ID' to pass in a url.. And it's odd because the query is pulling everything BUT the ID which is the first field... code: a href=view.php?ID=?php echo $_SESSION['fullRestaurantList']['ID']??php echo htmlspecialchars(stripslashes($_SESSION['fullRestaurantList'][$i]['name'])); ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to build an FF extension
Ashley Sheridan wrote: Wikipedia can hardly be accounted an official source of anything, especially considering how it gets the content! If you want official, then http://www.mozilla.com/en-US/firefox/releases/1.5.html is a good link. Wikipedia is the official source of Wikipedia information *mehehe* FWIW, I, and most of the people I know, write FF in emails. I didn't know Fx is supposed to be the official acronym. I think most people would think WTH if you wrote Fx. 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] How to build an FF extension
On Thu, Jul 23, 2009 at 10:15 AM, Robert Cummingsrob...@interjinn.com wrote: Ashley Sheridan wrote: Wikipedia can hardly be accounted an official source of anything, especially considering how it gets the content! If you want official, then http://www.mozilla.com/en-US/firefox/releases/1.5.html is a good link. Wikipedia is the official source of Wikipedia information *mehehe* FWIW, I, and most of the people I know, write FF in emails. I didn't know Fx is supposed to be the official acronym. I think most people would think WTH if you wrote Fx. Cheers, Rob. You beat me to it. :-) I've never seen Fx in reference to Firefox. I've only ever seen FF. Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to build an FF extension
Ashley Sheridan wrote: On Thu, 2009-07-23 at 14:39 +0100, Luke wrote: 2009/7/23 Ashley Sheridan a...@ashleysheridan.co.uk On Wed, 2009-07-22 at 23:49 -0400, Paul M Foster wrote: On Wed, Jul 22, 2009 at 08:31:10PM -0700, Javed Khan wrote: How to build an FF extension and how to install it. I'm using Fedora 10 operating system. Can someone please provide me with the steps Thanks J.K Let me substitute for Dan here. You're asking this on a PHP list, which isn't the appropriate venue for such a question. Firefox/Mozilla lists would be a better place to ask. Paul -- Paul M. Foster I'm not sure those lists could help him either, as the abbreviation for Firefox is Fx, not FF. Thanks Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Only officially: http://en.wikipedia.org/wiki/FFhttp://en.wikipedia.org/wiki/FF Wikipedia can hardly be accounted an official source of anything, especially considering how it gets the content! If you want official, then http://www.mozilla.com/en-US/firefox/releases/1.5.html is a good link. Thanks Ash www.ashleysheridan.co.uk +5 Useless Conversation What's FF then? What is he trying to build an extension for? http://www.acronymfinder.com/FF.html Says he wants to build an extension for Firefox, or Final Fantasy. Does Final Fantasy support PHP?
Re: [PHP] How to build an FF extension
Robert Cummings wrote: Ashley Sheridan wrote: Wikipedia can hardly be accounted an official source of anything, especially considering how it gets the content! If you want official, then http://www.mozilla.com/en-US/firefox/releases/1.5.html is a good link. Wikipedia is the official source of Wikipedia information *mehehe* FWIW, I, and most of the people I know, write FF in emails. I didn't know Fx is supposed to be the official acronym. I think most people would think WTH if you wrote Fx. Cheers, Rob. Rob, in fact, I would think WTF if you wrote Fx, I may even check my periodic table. Then again, I tend to think in obscene acronyms. - Kyle
Re: [PHP] Undefined Index ...confusion
Miller, Terion wrote: I keep getting this error while trying to use the field 'ID' to pass in a url.. And it's odd because the query is pulling everything BUT the ID which is the first field... code: a href=view.php?ID=?php echo $_SESSION['fullRestaurantList']['ID']??php echo htmlspecialchars(stripslashes($_SESSION['fullRestaurantList'][$i]['name'])); ? We're going to need to know how the $_SESSION['fullRestaurantList'] gets populated. Also, where do you define $i? Is $i the ID? Seemed like you've built an array of arrays and you may want $_SESSION['fullRestaurantList'][$i]['ID'], or just $i. This is all speculation from the 2 lines of code I've seen though. - Kyle
[PHP] Re: Undefined Index ...confusion
Miller, Terion wrote: I keep getting this error while trying to use the field 'ID' to pass in a url.. And it's odd because the query is pulling everything BUT the ID which is the first field... code: a href=view.php?ID=?php echo $_SESSION['fullRestaurantList']['ID']??php echo htmlspecialchars(stripslashes($_SESSION['fullRestaurantList'][$i]['name'])); ? What's the query? I find (I use PostgreSQL rather than the mySQL that many on this list use) that unless you explicitly ask for a field called ID (using SELECT ID ... ) you get a returned field in lower case So $resource = pg_query(SELECT ID, Foo FROM MyTable WHERE Foo='Bar'); $data = pg_fetch_all($resource) gives me an array $data of rows like $data[0]['id'] = '1' $data[0]['foo'] = 'Bar' To make sure $data[] has fields named ID and Foo I would have to do $resource = pg_query(SELECT ID AS \ID\, Foo AS \Foo\ FROM MyTable WHERE Foo='Bar'); -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Undefined Index ...confusion
On 7/23/09 9:24 AM, Kyle Smith kyle.sm...@inforonics.com wrote: Miller, Terion wrote: I keep getting this error while trying to use the field 'ID' to pass in a url.. And it's odd because the query is pulling everything BUT the ID which is the first field... code: a href=view.php?ID=?php echo $_SESSION['fullRestaurantList']['ID']??php echo htmlspecialchars(stripslashes($_SESSION['fullRestaurantList'][$i]['name'])); ? We're going to need to know how the $_SESSION['fullRestaurantList'] gets populated. Also, where do you define $i? Is $i the ID? Seemed like you've built an array of arrays and you may want $_SESSION['fullRestaurantList'][$i]['ID'], or just $i. This is all speculation from the 2 lines of code I've seen though. - Kyle The full script is (I have my Entourage email settings on html so I hope this displays ok for you all---seems I've been told it turns into a mess in some views) : ?php // Check if page is set to show all if(isset($_GET['show']) $_GET['show'] == 'all') { unset($_SESSION['results']); unset($_SESSION['searchname']); unset($_SESSION['address']); }// Check if there was an empty search sent if(isset($_SESSION['noVarsSent'])){ echo pbNo values were submitted for the search./b/p; // Unset it so a reload of page doesn't redisplay the error unset($_SESSION['noVarsSent']); // unset($_SESSION['results']);} // Check if full list of restaurants has been created and stored yet// Store full results in $_SESSION to limit database hits if(!isset($_SESSION['fullRestaurantList'])) { // List not grabbed yet, so run query and store in $_SESSION //check for rangeif (!(isset($rangenum))) { $rangenum = 1; } // Grab all restaurants in alphabetical order $sql = SELECT restaurants.ID, name, address, inDate, inType, notes, critical, cviolations, noncritical FROM restaurants, inspections WHERE restaurants.name != '' AND restaurants.ID = inspections.ID ORDER BY name;; $result = mysql_query($sql) or die(mysql_error()); //trying to grab it by ranges from the db? $rows = mysql_num_rows($result); $page_rows = 100; $last_row = ceil($rows/$page_rows); if ($rangenum 1) { $rangenum = 1; } elseif ($rangenum $last_row) { $rangenum = $last_row; } //This sets the range to display in our query $max = 'limit ' .($rangenum - 1) * $page_rows .',' .$page_rows; // Process all results into $_SESSION array $position = 1;
Re: [PHP] Structure of PHP files
On Thu, Jul 23, 2009 at 09:34:37AM -0400, Robert Cummings wrote: snip Not that I disagree with your methodology at this time, but you could have just made that single big file, include all those little files and still had a single load statement in each of your consumer source files. With compile caches the burden of loading all that code at startup is rather negligible :) I've heard this before, and I don't understand why people say this. If you have a 150k file you load before displaying a page, you've still occupied the CPU with the task of loading a 150k file. What happens to it afterward (compiling, compressing, caching, whatever) is another issue. You've still loaded 150k of code. The question is whether you actually need to load 150k of code from the start. If not, why waste the resources? Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Undefined Index ...confusion
Miller, Terion wrote: On 7/23/09 9:24 AM, Kyle Smith kyle.sm...@inforonics.com wrote: Miller, Terion wrote: I keep getting this error while trying to use the field 'ID' to pass in a url.. And it's odd because the query is pulling everything BUT the ID which is the first field... code: a href=view.php?ID=?php echo $_SESSION['fullRestaurantList']['ID']??php echo htmlspecialchars(stripslashes($_SESSION['fullRestaurantList'][$i]['name'])); ? We're going to need to know how the $_SESSION['fullRestaurantList'] gets populated. Also, where do you define $i? Is $i the ID? Seemed like you've built an array of arrays and you may want $_SESSION['fullRestaurantList'][$i]['ID'], or just $i. This is all speculation from the 2 lines of code I've seen though. - Kyle The full script is (I have my Entourage email settings on html so I hope this displays ok for you all---seems I've been told it turns into a mess in some views) : It sure did turn into a big mess. Could you try using a pastebin service? You should do this as a general best-practice anyway. Long email threads tend to turn people off to helping you. Go here: http://pastebin.ca/ Paste your code and select PHP for Syntax Highlighting, then click submit. You'll be given a short URL to share with the thread that will bring us to an easy-to-read version of your code. - Kyle
Re: [PHP] Structure of PHP files
Paul M Foster wrote: On Thu, Jul 23, 2009 at 09:34:37AM -0400, Robert Cummings wrote: snip Not that I disagree with your methodology at this time, but you could have just made that single big file, include all those little files and still had a single load statement in each of your consumer source files. With compile caches the burden of loading all that code at startup is rather negligible :) I've heard this before, and I don't understand why people say this. If you have a 150k file you load before displaying a page, you've still occupied the CPU with the task of loading a 150k file. What happens to it afterward (compiling, compressing, caching, whatever) is another issue. You've still loaded 150k of code. The question is whether you actually need to load 150k of code from the start. If not, why waste the resources? 150k is peanuts and having it already in memory means it doesn't have to be loaded later. With a compile cache it's quite likely that over time you'll have the 150k loaded into memory anyways. It's just going to take longer for it to be loaded since the compile cache has to encounter it first. Once encountered it's still occupying the same memory. Additionally, the operating system does an excellent job of swapping memory not being accessed regularly (if it needs memory). 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
[Fwd: Re: [PHP] Undefined Index ...confusion]
Sorry, list, I did a reply instead of a reply-to-all. This is what I sent to Miller, Terion Miller, Terion wrote: Thanks for the link Kyle!! Great thing there...(seriously I didn't know...I learn something everyday) Anyways the link to my script is: http://pastebin.ca/1504393 Your email client is annoying, it doesn't quote. Haha. Anyway, so, you're loading up that array with arrays of arrays, here: 1. $position = 1; 2. 3. while ($row = mysql_fetch_array http://www.php.net/mysql_fetch_array($result)) 4. { 5. $_SESSION['fullRestaurantList'][$position] = $row; 6. $position++; 7. } 8. 9. $_SESSION['totalNumberOfRestaurants'] = $position; So, if you get 7 rows. Your array will have: Array = (Row 1 Data) Array = (Row 2 Data) .. etc You do not have ['fullRestaurantList']['ID']. In the page you're referencing you use something like $_SESSION['fullRestaurantList'][$i]['SomeValue']. I assume $i is the Position in the array, so you likely want to use $_SESSION['fullRestaurantList'][$i]['ID'] to get the ID field from that row. If you need a quick dump to better understand what data you have in your session, try making a page called session_dump.php in the same directory with this source: pre? print_r($_SESSION) ?/pre That will give you a good idea of what your session array looks like, and you should see clearly that ['fullRestaurantList']['ID'] does not exist. Hope this helps! - Kyle
Re: [PHP] How to build an FF extension
On Thu, Jul 23, 2009 at 10:21 AM, Kyle Smithkyle.sm...@inforonics.com wrote: Robert Cummings wrote: Ashley Sheridan wrote: Wikipedia can hardly be accounted an official source of anything, especially considering how it gets the content! If you want official, then http://www.mozilla.com/en-US/firefox/releases/1.5.html is a good link. Wikipedia is the official source of Wikipedia information *mehehe* FWIW, I, and most of the people I know, write FF in emails. I didn't know Fx is supposed to be the official acronym. I think most people would think WTH if you wrote Fx. Cheers, Rob. Rob, in fact, I would think WTF if you wrote Fx, I may even check my periodic table. Then again, I tend to think in obscene acronyms. - Kyle Isn't Fx used to denote Adobe Flex? Thought I've seen some icons with Fx for that -- Bastien Cat, the other other white meat -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: unsetting a referenced parameter in a function
-Original Message- From: Shawn McKenzie [mailto:nos...@mckenzies.net] Sent: 23 July 2009 02:36 PM To: php-general@lists.php.net Subject: Re: [PHP] Re: unsetting a referenced parameter in a function Tom Worster wrote: On 7/22/09 6:09 PM, Shawn McKenzie nos...@mckenzies.net wrote: Tom Worster wrote: though the manual is perfectly clear that this should be expected, i was a bit surprised that the result of the following is 42 ?php function foo($a) { $a = 42; unset($a); $a = 'meaning'; } foo($a); print($a\n); ? normally i would expect unset() to free some memory. but in this example it doesn't and has a different behavior: it releases foo's reference to the global $a, allowing the next line to define a local $a. i think i'd have preferred compile error. Well, you unset the reference and then you assigned 'meaning' to a local function variable $a. Why would you get a compile error? when you state it in those terms (which are clearly correct) i wouldn't. but if the way i think is unset() destroys the specified variables (as the manual puts it) then i expect that the specified variable would be destroyed, not the reference. so, as i said, i was a bit surprised when the variable wasn't destroyed. once i understood what was happening, i thought it a bit confusing to have such scope-dependent differences in behavior of a language element. It might be easier to understand if you don't use the same var names: function foo($arg) { $arg = 42; unset($arg); $arg = 'meaning'; } $a = 0; foo($a); print($a\n); -Shawn -- Another way to see it (from Shawn's example): the is an address of (reference to) a variable, so function foo($arg) creates a local variable $arg pointing to a global variable called $a. Changing the value of local $arg updates the global $a. The unset($arg) removes the local $arg but has no effect on global $a. The next line $arg = 'meaning' creates a new local variable called $arg which has no connection whatsoever with the $arg that was unset - it could just as well have been called $xyz. As Shawn pointed out there's no problem here with scope, you were just confusing yourself by using the same variable name in the function, but it's a separate local variable regardless of what name you give it. A slight variation of your example: ?php function foo() { global $a; $a = 42; unset($a); $a = 'meaning'; } $a = 0; foo($a); print($a\n); ? You get exactly the same result as your example, for the same reason, the only difference is that you obviously can't change the local variable name in the function. A final variation (to drive the point home): function foo($arg) { global $a; $a = 42;== at this point $arg = 42 unset($a); $a = 'meaning'; == $arg is still 42 $a = $arg; == $a now points to same address $arg is pointing to $a = 'of life'; == $arg now = 'of life' } $a = 0; foo($a); print($a\n); == prints 'of life' Here in function foo() local $arg and local $a are both pointing to the global $a, and changing either of them changes the other (and changes the global variable). After unset($a) only local $arg is pointing to global $a. After $a = $arg both local variables are again pointing to global $a, and local $a value has therefor obviously changed from 'meaning' to 42. Then after $a = 'of life' both local variables and the global $a is changed to 'of life'. Local $a and global $a have the same names but are different variables. Also, the local $a after unset($a) happens to have the same name as the $a before unset($a) but it's a different variable, it could just as easily been called $b after unset($a). A final point: the global $a; in the function doesn't mean it's THE global $a, it just means it's a local variable called $a pointing to (referencing) a global variable with the same name. In PHP it has to be the same name because that's the way the global statement works, but it can sometimes create the impression that it's the same variable. Hope I haven't made that as clear as mud. Cheers Arno -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Renaming all variables in a repository
Hey all, we've got a repository here at work, with something like 55,000 files in it. For the last few years, we've been naming $variables_like_this and functions_the_same($way_too). And now we've decided to switch to camelCasing everything and I've been tasked with somehow determining if it's possible to automate this process. Usually, I'd just use the IDE refactoring functionality, but doing it on a per-method/per-function and a per-variable basis would take weeks, if not longer, not to mention driving everyone insane. I've tried with regular expressions, but I can't make them smart enough to distinguish between builtins and userland code. I've looked at the tokenizer and it seems to be the right way forward, but that's also a huge project to get that to work. I was wondering if anyone had had any experience doing this and could either point me in the right direction or just down and out tell me how to do it. Thanks so much --Eddie -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Renaming all variables in a repository
Eddie Drapkin wrote: Hey all, we've got a repository here at work, with something like 55,000 files in it. For the last few years, we've been naming $variables_like_this and functions_the_same($way_too). And now we've decided to switch to camelCasing everything and I've been tasked with somehow determining if it's possible to automate this process. Usually, I'd just use the IDE refactoring functionality, but doing it on a per-method/per-function and a per-variable basis would take weeks, if not longer, not to mention driving everyone insane. I've tried with regular expressions, but I can't make them smart enough to distinguish between builtins and userland code. I've looked at the tokenizer and it seems to be the right way forward, but that's also a huge project to get that to work. I was wondering if anyone had had any experience doing this and could either point me in the right direction or just down and out tell me how to do it. Are any of these variables created by exporting an array to variables? Are any of these variables global or otherwise and subsequently accessed via an array and key? It may not just be a case of finding and replacing variable names. It may also be a case of finding and replacing any array keys that also follow the underscore system. 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] Compare PHP settings of two different servers
PHP Gurus, I'm currently having a problem with PHP writing text to a PNG image on one server. I have various web sites hosted on various servers, and on most of them, the script that generates the image is writing text properly. I have ensured that the same fonts are available on all the servers. My first guess was that the PHP environment on the misbehaving server was missing a GD module, like the TTF module or something. As far as I can tell by looking over the phpinfo() settings, the servers have all the same modules. But maybe I'm just not seeing it, because manually going over the settings is prone to human error. Is there a way I can take the output of phpinfo() from both servers and do a compare that will tell me what the differences are? Alternatively, if anyone has any suggestions on what might be a cause of not getting text onto an image, I'm open to any ideas. Thanks for any advice. -- Dave M G -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Renaming all variables in a repository
function toCamelCase( $string ) { return str_replace( ' ' , '', ucwords( strtolower( strtr($string, '_', ' ') ) )); } echo toCamelCase( 'this_is_not_properly_written' ); You can use this simplest function to translate a string to camelCase. The process could be... 1) parse by PHP 2) translate tokens to camelCase 3) writte the file with changes You can easily parse a php file using http://php.net/token_get_all On Thu, Jul 23, 2009 at 1:56 PM, Eddie Drapkin oorza...@gmail.com wrote: Hey all, we've got a repository here at work, with something like 55,000 files in it. For the last few years, we've been naming $variables_like_this and functions_the_same($way_too). And now we've decided to switch to camelCasing everything and I've been tasked with somehow determining if it's possible to automate this process. Usually, I'd just use the IDE refactoring functionality, but doing it on a per-method/per-function and a per-variable basis would take weeks, if not longer, not to mention driving everyone insane. I've tried with regular expressions, but I can't make them smart enough to distinguish between builtins and userland code. I've looked at the tokenizer and it seems to be the right way forward, but that's also a huge project to get that to work. I was wondering if anyone had had any experience doing this and could either point me in the right direction or just down and out tell me how to do it. Thanks so much --Eddie -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Martin Scotta
RE: [PHP] Renaming all variables in a repository
In a project with this large number of files, is better if you let the way it is, doing this now you can crash the project and lost much much time. Yuri Yarlei. Programmer PHP, CSS, Java, PostregreSQL; Today PHP, tomorrow Java, after the world. Kyou wa PHP, ashita wa Java, sono ato sekai desu. Date: Thu, 23 Jul 2009 12:56:51 -0400 From: oorza...@gmail.com To: php-general@lists.php.net Subject: [PHP] Renaming all variables in a repository Hey all, we've got a repository here at work, with something like 55,000 files in it. For the last few years, we've been naming $variables_like_this and functions_the_same($way_too). And now we've decided to switch to camelCasing everything and I've been tasked with somehow determining if it's possible to automate this process. Usually, I'd just use the IDE refactoring functionality, but doing it on a per-method/per-function and a per-variable basis would take weeks, if not longer, not to mention driving everyone insane. I've tried with regular expressions, but I can't make them smart enough to distinguish between builtins and userland code. I've looked at the tokenizer and it seems to be the right way forward, but that's also a huge project to get that to work. I was wondering if anyone had had any experience doing this and could either point me in the right direction or just down and out tell me how to do it. Thanks so much --Eddie -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php _ Novo Internet Explorer 8. Baixe agora, é grátis! http://brasil.microsoft.com.br/IE8/mergulhe/?utm_source=MSN%3BHotmailutm_medium=Taglineutm_campaign=IE8
Re: [PHP] Compare PHP settings of two different servers
Dave M G wrote: PHP Gurus, I'm currently having a problem with PHP writing text to a PNG image on one server. I have various web sites hosted on various servers, and on most of them, the script that generates the image is writing text properly. I have ensured that the same fonts are available on all the servers. My first guess was that the PHP environment on the misbehaving server was missing a GD module, like the TTF module or something. As far as I can tell by looking over the phpinfo() settings, the servers have all the same modules. But maybe I'm just not seeing it, because manually going over the settings is prone to human error. Is there a way I can take the output of phpinfo() from both servers and do a compare that will tell me what the differences are? Alternatively, if anyone has any suggestions on what might be a cause of not getting text onto an image, I'm open to any ideas. Thanks for any advice. In linux you would use the diff command to compare two files. 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] Compare PHP settings of two different servers
2009/7/23 Dave M G mar...@autotelic.com: Is there a way I can take the output of phpinfo() from both servers and do a compare that will tell me what the differences are? Just diff the HTML. WinMerge, Kompare, etc etc. Or probably built into your favourite IDE. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Renaming all variables in a repository
Eddie Drapkin wrote: Hey all, we've got a repository here at work, with something like 55,000 files in it. For the last few years, we've been naming $variables_like_this and functions_the_same($way_too). And now we've decided to switch to camelCasing everything and I've been tasked with somehow determining if it's possible to automate this process. Usually, I'd just use the IDE refactoring functionality, but doing it on a per-method/per-function and a per-variable basis would take weeks, if not longer, not to mention driving everyone insane. I've tried with regular expressions, but I can't make them smart enough to distinguish between builtins and userland code. I've looked at the tokenizer and it seems to be the right way forward, but that's also a huge project to get that to work. I was wondering if anyone had had any experience doing this and could either point me in the right direction or just down and out tell me how to do it. Hi Eddie, That's quite the task :). You're going to need to scan the source to generate a list of every variable and function name using the tokenizer. Fortunately, this is easy - with the caveat that if you do this anywhere in your source: $a = $this-{$constructed . '_name'}(); you will have to handle these manually. Basically, run token_get_all() on the source, scanning for T_VARIABLE, and record every T_VARIABLE in an array. Then, scan for: 1) T_FUNCTION T_WHITESPACE* T_STRING 2) T_OBJECT_OPERATOR T_WHITESPACE* T_STRING ?php $replace = array(); foreach (new RegexIterator(new RecursiveIteratorIterator(new RecursiveDirectoryIterator('/path/to/src')), '/\.php$/', RegexIterator::MATCH, RegexIterator::USE_KEY) as $path = $file) { $source = file_get_contents($path); $checkForID = false; $var = false; $last = ''; foreach (token_get_all($source) as $token) { if (!is_array($token)) continue; if ($checkForID) { if ($token[0] == T_WHITESPACE) { $last .= $token[1]; continue; } if ($token[0] != T_STRING) { $checkForID = false; $last = ''; continue; } $token[1] = $last . $token[1]; } elseif ($token[0] == T_FUNCTION || $token[0] == T_OBJECT_OPERATOR) { $checkForID = true; $last = $token[1]; continue; } elseif ($token[0] == T_STRING) { if (function_exists($token[1])) { continue; // skip internal functions } if (strtolower($token[1]) != $token[1]) { continue; // assuming you UPPER-CASE constants, this skips them } } elseif ($token[0] != T_VARIABLE) { continue; } // we get to here if we've found one to process $new = explode('_', $token[1]); $new = array_map('ucfirst', $new); $new[0] = lcfirst($new); // for your camelCasing $new = implode('', $new); $replace[] = array($token[1], $new); ? Next, load each file (you should use RecursiveIteratorIterator with a RecursiveDirectoryIterator and some kind of filter, probably RegexIterator, to grab the PHP source files), and then iterate over the list of variable names somewhat like this: ?php foreach (new RegexIterator(new RecursiveIteratorIterator(new RecursiveDirectoryIterator('/path/to/src')), '/\.php$/', RegexIterator::MATCH, RegexIterator::USE_KEY) as $path = $file) { $source = file_get_contents($path); foreach ($replace as $items) { $source = str_replace($items[0], $items[1], $source); if ($items[0][0] == '$') { $source = preg_replace('/-(\s*)' . substr($variable, 1) . '/', '-\\1'substr($new, 1), $source); } } file_put_contents($path, $source); } ? Voila, code refactored. I trust you know this, but don't run that example code without testing it on a limited sandbox and comparing the results first :). I did not test anything except the regexiterator part to make sure that it actually grabbed PHP files, the rest is based on my experience tokenizing for parsing PHP when writing tools like phpDocumentor. If I made any mistakes, it would be good for you to post your final scripts for posterity back on here. Greg -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Compare PHP settings of two different servers
David, Robert, Thank you for replying. Just diff the HTML. Unfortunately it is not that easy. Even if the same PHP modules are present, if they are written into the page in a different place, they show up as differences. The same goes for all the HTML tags and everything else, so what I end up with is a ton of text, no more streamlined or easy to analyze than the original output from phpinfo(). I'm hoping there's a way more targeted way of discerning what settings one server may have that another server might not. -- Dave M G -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Compare PHP settings of two different servers
From: Dave M G Thank you for replying. Just diff the HTML. Unfortunately it is not that easy. Even if the same PHP modules are present, if they are written into the page in a different place, they show up as differences. The same goes for all the HTML tags and everything else, so what I end up with is a ton of text, no more streamlined or easy to analyze than the original output from phpinfo(). I'm hoping there's a way more targeted way of discerning what settings one server may have that another server might not. Save each page to a text file. Sort the two text files. Run 'diff -iw' on the sorted files. Add additional flags to diff as needed. If you need more than that, you will probably have to write your own utility to handle it. You should also get copies of httpd.conf and php.ini from each server and compare them. They will affect how some of those modules behave. Bob McConnell -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Compare PHP settings of two different servers
From: Dave M G I'm currently having a problem with PHP writing text to a PNG image on one server. I have various web sites hosted on various servers, and on most of them, the script that generates the image is writing text properly. I have ensured that the same fonts are available on all the servers. Another thought comes to mind. What text encoding are you using and what are the locale settings on those servers? Bob McConnell -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Renaming all variables in a repository
On Thu, Jul 23, 2009 at 1:50 PM, Greg Beaverg...@chiaraquartet.net wrote: Eddie Drapkin wrote: Hey all, we've got a repository here at work, with something like 55,000 files in it. For the last few years, we've been naming $variables_like_this and functions_the_same($way_too). And now we've decided to switch to camelCasing everything and I've been tasked with somehow determining if it's possible to automate this process. Usually, I'd just use the IDE refactoring functionality, but doing it on a per-method/per-function and a per-variable basis would take weeks, if not longer, not to mention driving everyone insane. I've tried with regular expressions, but I can't make them smart enough to distinguish between builtins and userland code. I've looked at the tokenizer and it seems to be the right way forward, but that's also a huge project to get that to work. I was wondering if anyone had had any experience doing this and could either point me in the right direction or just down and out tell me how to do it. Hi Eddie, That's quite the task :). You're going to need to scan the source to generate a list of every variable and function name using the tokenizer. Fortunately, this is easy - with the caveat that if you do this anywhere in your source: $a = $this-{$constructed . '_name'}(); you will have to handle these manually. Basically, run token_get_all() on the source, scanning for T_VARIABLE, and record every T_VARIABLE in an array. Then, scan for: 1) T_FUNCTION T_WHITESPACE* T_STRING 2) T_OBJECT_OPERATOR T_WHITESPACE* T_STRING ?php $replace = array(); foreach (new RegexIterator(new RecursiveIteratorIterator(new RecursiveDirectoryIterator('/path/to/src')), '/\.php$/', RegexIterator::MATCH, RegexIterator::USE_KEY) as $path = $file) { $source = file_get_contents($path); $checkForID = false; $var = false; $last = ''; foreach (token_get_all($source) as $token) { if (!is_array($token)) continue; if ($checkForID) { if ($token[0] == T_WHITESPACE) { $last .= $token[1]; continue; } if ($token[0] != T_STRING) { $checkForID = false; $last = ''; continue; } $token[1] = $last . $token[1]; } elseif ($token[0] == T_FUNCTION || $token[0] == T_OBJECT_OPERATOR) { $checkForID = true; $last = $token[1]; continue; } elseif ($token[0] == T_STRING) { if (function_exists($token[1])) { continue; // skip internal functions } if (strtolower($token[1]) != $token[1]) { continue; // assuming you UPPER-CASE constants, this skips them } } elseif ($token[0] != T_VARIABLE) { continue; } // we get to here if we've found one to process $new = explode('_', $token[1]); $new = array_map('ucfirst', $new); $new[0] = lcfirst($new); // for your camelCasing $new = implode('', $new); $replace[] = array($token[1], $new); ? Next, load each file (you should use RecursiveIteratorIterator with a RecursiveDirectoryIterator and some kind of filter, probably RegexIterator, to grab the PHP source files), and then iterate over the list of variable names somewhat like this: ?php foreach (new RegexIterator(new RecursiveIteratorIterator(new RecursiveDirectoryIterator('/path/to/src')), '/\.php$/', RegexIterator::MATCH, RegexIterator::USE_KEY) as $path = $file) { $source = file_get_contents($path); foreach ($replace as $items) { $source = str_replace($items[0], $items[1], $source); if ($items[0][0] == '$') { $source = preg_replace('/-(\s*)' . substr($variable, 1) . '/', '-\\1'substr($new, 1), $source); } } file_put_contents($path, $source); } ? Voila, code refactored. I trust you know this, but don't run that example code without testing it on a limited sandbox and comparing the results first :). I did not test anything except the regexiterator part to make sure that it actually grabbed PHP files, the rest is based on my experience tokenizing for parsing PHP when writing tools like phpDocumentor. If I made any mistakes, it would be good for you to post your final scripts for posterity back on here. Greg Thanks so much, man. I'm using most of your methodology, although there were definitely some hiccups along the way, but it seems to make a map of what to replace and what to replace with so far, although the code is far from pretty. I'll be sure to send it to the list when it's done. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Converting SQL Dialects
You might even be able to convert EMPTY(X) to COALESCE(X, '') = ''. MySQL seems to be pretty forgiving with its implicit type-casting. Hmm... The new system I've written properly handles the datatype and EMPTY... So this would be a hack to much around with regexs to replace EMPTY in customer built selects. Now I fiddled around with this on 5.1.33-community on Windows and I get the following odd results... select coalesce(0,)=0,coalesce(,)=0,coalesce(0,)=0,coalesce(,)=0; returns 1, 1, 1, 1 but... select coalesce(0,)=,coalesce(,)=,coalesce(0,)=,coalesce(,)=; returns 0, 1, 0, 1 Which implies that in certain circumstances = 0 but 0 != (unless I'm missing something). Either way it looks like I can use coalesce(X,)=0 which should be useful! Matt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Converting SQL Dialects
On Thu, Jul 23, 2009 at 3:39 PM, Matt Neimeyerm...@neimeyer.org wrote: You might even be able to convert EMPTY(X) to COALESCE(X, '') = ''. MySQL seems to be pretty forgiving with its implicit type-casting. Hmm... The new system I've written properly handles the datatype and EMPTY... So this would be a hack to much around with regexs to replace EMPTY in customer built selects. Now I fiddled around with this on 5.1.33-community on Windows and I get the following odd results... select coalesce(0,)=0,coalesce(,)=0,coalesce(0,)=0,coalesce(,)=0; returns 1, 1, 1, 1 but... select coalesce(0,)=,coalesce(,)=,coalesce(0,)=,coalesce(,)=; returns 0, 1, 0, 1 Which implies that in certain circumstances = 0 but 0 != (unless I'm missing something). Either way it looks like I can use coalesce(X,)=0 which should be useful! Matt That is interesting. The whole purpose of the COALESCE function in SQL is to substitute a non-null value for a null value. Since there aren't any nulls in either of your statements, you are effectively running these: select 0=0, ''=0, 0=0, ''=0 select 0='', ''='', 0='', ''='' COALESCE(X, '') = 0 is probably the better option though, since the result of COALESE should be implicitly cast to the datatype of X before performing the equality comparison. In MySQL, casting an empty string to an integer would result in the value 0 while casting to a date would produce the date value equivalent to the integer 0. The benefit of COALESCE is that it should be standard SQL. I know it works on MySQL and SQL Server, and I think it works on Oracle and others as well. You may take a performance hit for using COALESCE in conditions like that since it usually means the condition can't use an index, but considering you're moving from using similar logic in FoxPro that may not matter for you. Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [Fwd: Re: [PHP] Undefined Index ...confusion] (RESOLVED)
Thanks On 7/23/09 9:52 AM, Kyle Smith kyle.sm...@inforonics.com wrote: Sorry, list, I did a reply instead of a reply-to-all. This is what I sent to Miller, Terion Miller, Terion wrote: Thanks for the link Kyle!! Great thing there...(seriously I didn't know...I learn something everyday) Anyways the link to my script is: http://pastebin.ca/1504393 Your email client is annoying, it doesn't quote. Haha. Anyway, so, you're loading up that array with arrays of arrays, here: 1. $position = 1; 2. 3. while ($row = mysql_fetch_array http://www.php.net/mysql_fetch_arrayhttp://www.php.net/mysql_fetch_array($result)) 4. { 5. $_SESSION['fullRestaurantList'][$position] = $row; 6. $position++; 7. } 8. 9. $_SESSION['totalNumberOfRestaurants'] = $position; So, if you get 7 rows. Your array will have: Array = (Row 1 Data) Array = (Row 2 Data) .. etc You do not have ['fullRestaurantList']['ID']. In the page you're referencing you use something like $_SESSION['fullRestaurantList'][$i]['SomeValue']. I assume $i is the Position in the array, so you likely want to use $_SESSION['fullRestaurantList'][$i]['ID'] to get the ID field from that row. If you need a quick dump to better understand what data you have in your session, try making a page called session_dump.php in the same directory with this source: pre? print_r($_SESSION) ?/pre That will give you a good idea of what your session array looks like, and you should see clearly that ['fullRestaurantList']['ID'] does not exist. Hope this helps! - Kyle -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Renaming all variables in a repository
2009/7/23 Eddie Drapkin oorza...@gmail.com: Hey all, we've got a repository here at work, with something like 55,000 files in it. For the last few years, we've been naming $variables_like_this and functions_the_same($way_too). And now we've decided to switch to camelCasing everything and I've been tasked with somehow determining if it's possible to automate this process. Usually, I'd just use the IDE refactoring functionality, but doing it on a per-method/per-function and a per-variable basis would take weeks, if not longer, not to mention driving everyone insane. I've tried with regular expressions, but I can't make them smart enough to distinguish between builtins and userland code. I've looked at the tokenizer and it seems to be the right way forward, but that's also a huge project to get that to work. I was wondering if anyone had had any experience doing this and could either point me in the right direction or just down and out tell me how to do it. I'd question the wisdom of doing such a thing at all. When it comes to coding standards the important thing is not what they are, just that they exist and are observed by everybody. This sounds like a colossal waste of time, whether you can find an automated method or not, for no apparent gain. Seriously, what's the benefit of using camel over underscores? Sounds like a decision made by a manager who feels the need to create work when none is actually required. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Question on code profiling
I'm trying to profile a site on our development server to see why it takes around 4 seconds to generate a pretty basic page. I installed xdebug to use for the profiling, and now I'm really confused. Even though it takes around 4 seconds to build the entire page, the profile says that the total processing time is around 416ms. I thought it might be calls to require_once/include/include_once. While they are significant (around 46%), it says they only account for 193ms. What could account for that much difference between what xdebug calculates versus the total elapsed time? Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question on code profiling
Andrew Ballard wrote: I'm trying to profile a site on our development server to see why it takes around 4 seconds to generate a pretty basic page. I installed xdebug to use for the profiling, and now I'm really confused. Even though it takes around 4 seconds to build the entire page, the profile says that the total processing time is around 416ms. I thought it might be calls to require_once/include/include_once. While they are significant (around 46%), it says they only account for 193ms. What could account for that much difference between what xdebug calculates versus the total elapsed time? Andrew Any embedded remote elements in it like that punk Google analytics which I often see lagging my page requests on various sites? 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] Compare PHP settings of two different servers
Thank you for replying. Just diff the HTML. Unfortunately it is not that easy. Even if the same PHP modules are present, if they are written into the page in a different place, they show up as differences. The same goes for all the HTML tags and everything else, so what I end up with is a ton of text, no more streamlined or easy to analyze than the original output from phpinfo(). Do you have shell access on these servers, and are they running Linux or the like? If so, this seems like what you'd want: php -i | sort -u Ben -- Twitter: @bdunlap -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question on code profiling
Nope. Basically it connects to a database to load an ACL (which at [...] I thought xdebug was supposed to be a pretty good profiler. If it calculating the time correctly, where are the other ~3.6 seconds going? One night I saw a script wait indefinitely for a response from a tanked database, and PHP's max_execution_time trigger never fired to end the script, even though it was set to a pretty low value. Some poking around led me to http://us.php.net/manual/en/function.set-time-limit.php where I found this odd note: Any time spent on activity that happens outside the execution of the script such as system calls using system(), stream operations, database queries, etc. is not included when determining the maximum time that the script has been running. This is not true on Windows where the measured time is real. The last sentence was particularly confusing because I was running on Windows. At any rate, if xdebug is using the same mechanism used by set_time_limit() and max_execution_time, perhaps that could explain your discrepancy? I second Jonathan's suggestion; I would try calling microtime() before and after your database query, and before and after anything else that isn't strictly execution of the script. Ben -- Twitter: @bdunlap -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Question on code profiling
Just an idea: try using the (microtime(true) - $start) approach in portions of code to try isolate the portion that is taking more time. Sometimes that helps me to find the function that is slowing everything down. Jonathan On Thu, Jul 23, 2009 at 6:18 PM, Andrew Ballardaball...@gmail.com wrote: On Thu, Jul 23, 2009 at 5:10 PM, Ben Dunlapbdun...@agentintellect.com wrote: significant (around 46%), it says they only account for 193ms. What could account for that much difference between what xdebug calculates versus the total elapsed time? Are you counting total elapsed time from the perspective of the web browser? If so, YSlow might be helpful: http://developer.yahoo.com/yslow/ Ben -- Twitter: @bdunlap I'm using YSlow too. Here's the last run I did: YSlow: 4.494 seconds Elapsed (microtime(true) - $start): 3.990795135498 seconds xdebug(WinCacheGrind): 402ms (0.402 seconds) Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP: Writing to CD/DVD?
On Fri, Jul 24, 2009 at 12:20 AM, Clancy clanc...@cybec.com.au wrote: Does anyone know of an extension/utility that will enable PHP to write backup files to a CD/DVD? Ideally I would like the CD to appear as 'just another drive'. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php If, 1. You are using linux 2. You can make system calls It will help: http://www.andrews-corner.org/burning.html -- Thanks, Diogo Neves Web Developer @ SAPO.pt by PrimeIT.pt
[PHP] PHP: Writing to CD/DVD?
Does anyone know of an extension/utility that will enable PHP to write backup files to a CD/DVD? Ideally I would like the CD to appear as 'just another drive'. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP: Writing to CD/DVD?
That's what I was just about writting. If you use linux -- you can shot calls to the system and watch it's response! Then all you have to do is to install a cd burning software which have an ability to control it through the terminal! Good luck mate! On Fri, Jul 24, 2009 at 1:47 AM, Diogo Neves dafne...@gmail.com wrote: On Fri, Jul 24, 2009 at 12:20 AM, Clancy clanc...@cybec.com.au wrote: Does anyone know of an extension/utility that will enable PHP to write backup files to a CD/DVD? Ideally I would like the CD to appear as 'just another drive'. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php If, 1. You are using linux 2. You can make system calls It will help: http://www.andrews-corner.org/burning.html -- Thanks, Diogo Neves Web Developer @ SAPO.pt by PrimeIT.pt
Re: [PHP] Doubt regarding session_destroy() in PHP 5
Ashley Sheridan a écrit : But *how* does it offer more security? You've not actually mentioned that! Because you need database slice access to manage the session, and not only file access in /tmp/ (where sessions belongs, by default). So now the problem is : and what about the configuration file that lies in my filesystem ? :D -- Mickaël Wolff aka Lupus Michaelis http://lupusmic.org Seeking for a position http://lupusmic.org/pro/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Mediawiki's url confusion
Thanks a lot. As far as i know, both methods dealing with urls are WEB-SERVER-TECH. While I was installing mediawiki, i did nothing with the file httpd.conf, no changes made on mod_rewrite. The mediawiki install script cannot do nothing to httpd.conf i think. So i'm confused about how the url-rewriting mechanism is activited. Best Wishes~ Deng 09/07/24 2009/7/23 Ford, Mike m.f...@leedsmet.ac.uk -Original Message- From: Paul M Foster [mailto:pa...@quillandmouse.com] Sent: 23 July 2009 06:13 On Thu, Jul 23, 2009 at 11:57:51AM +0800, ?? wrote: But I cannot help myself with the url pattern : /somepath_to_mediawiki/index.php/pagetitle. How can this kind of url be parsed to the file index.php and the pagetitle be parsed as params? Why the web server not go straight into path index.php/ and look for the file named pagetitle ? This type of thing is common for sites using the MVC or Model-View-Controller paradigm. The index.php file is what's called a front controller. A front controller is usually the entrance to all the other pages of a site. URLs like this often take advantage of an Apache feature called mod_rewrite, which tells Apache how to handle URLs which look like this. Or by the pathinfo mechanism, which I believe is also supported by other Web servers, and can work just as well, if it satisfies your requirements, without all the complications of mod_rewrite. 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] Re: Structure of PHP files
Sándor Tamás (HostWare Kft . ) a écrit : It isn't really a programming question, but rather a structural. It is part of our burden ;) Which is the better approach: They are no better approch, only bad ones. I'm using to organize my code in module. Each module require the needed modules. This design permit me to ease case testing, and ease maintenance because you know quite fast what module can be impact by the alteration of another. I never have to speak about scallability of this method, because I never work on a very big system. But that's optimization, I think it'll need some sed (sed -i 's/\require_once\/require_ondemand/' project/) and a strong mecanism to provide including on demand. -- Mickaël Wolff aka Lupus Michaelis http://lupusmic.org Seeking for a position http://lupusmic.org/pro/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Mediawiki's url confusion
On Thu, Jul 23, 2009 at 10:28 PM, Dengxule dengx...@gmail.com wrote: Thanks a lot. As far as i know, both methods dealing with urls are WEB-SERVER-TECH. While I was installing mediawiki, i did nothing with the file httpd.conf, no changes made on mod_rewrite. The mediawiki install script cannot do nothing to httpd.conf i think. So i'm confused about how the url-rewriting mechanism is activited. Best Wishes~ Deng 09/07/24 2009/7/23 Ford, Mike m.f...@leedsmet.ac.uk -Original Message- From: Paul M Foster [mailto:pa...@quillandmouse.com] Sent: 23 July 2009 06:13 On Thu, Jul 23, 2009 at 11:57:51AM +0800, ?? wrote: But I cannot help myself with the url pattern : /somepath_to_mediawiki/index.php/pagetitle. How can this kind of url be parsed to the file index.php and the pagetitle be parsed as params? Why the web server not go straight into path index.php/ and look for the file named pagetitle ? This type of thing is common for sites using the MVC or Model-View-Controller paradigm. The index.php file is what's called a front controller. A front controller is usually the entrance to all the other pages of a site. URLs like this often take advantage of an Apache feature called mod_rewrite, which tells Apache how to handle URLs which look like this. Or by the pathinfo mechanism, which I believe is also supported by other Web servers, and can work just as well, if it satisfies your requirements, without all the complications of mod_rewrite. 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 It could use a .htaccess file. Look in the directory of the index.php file for a file named .htaccess -- --Zootboy
Re: [PHP] Question on code profiling
On Thu, Jul 23, 2009 at 5:32 PM, Ben Dunlapbdun...@agentintellect.com wrote: I second Jonathan's suggestion; I would try calling microtime() before and after your database query, and before and after anything else that isn't strictly execution of the script. Ben I tried this where I could. (The ZF library itself is on a local machine drive where I don't have access to edit the files, so I can only edit files within the project itself. That means I can't inspect too deeply.) I'm starting to think perhaps there is a bug in either xdebug or WinCacheGrind. From what I can tell, the numbers I see in WinCacheGrind look like they are off by about a factor of 10 pretty uniformly. Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] A form and an array
Hello everyone, Lets say I have a file called form.php with the following form on it that redirects to index.php when submitted. I would like to take the values of the text fields in the form and put them into an array, then be able to display the values in that array on index.php Does anyone know how I would do that? Here is my form... form action=index.php method=post table tr tdOption1/td tdinput type=text name=option[] //td /tr tr tdOption2/td tdinput type=text name=option[] //td /tr tr td/td tdinput value=submit name=submit type=submit //td /tr /table /table/form -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: A form and an array
Jason Carson wrote: Jason Carson wrote: Hello everyone, Lets say I have a file called form.php with the following form on it that redirects to index.php when submitted. I would like to take the values of the text fields in the form and put them into an array, then be able to display the values in that array on index.php Does anyone know how I would do that? Here is my form... form action=index.php method=post table tr tdOption1/td tdinput type=text name=option[] //td /tr tr tdOption2/td tdinput type=text name=option[] //td /tr tr td/td tdinput value=submit name=submit type=submit //td /tr /table /table/form You'll find they are already in an array which you can access as $_POST['option'] - from there foreach() should be the next step. Cheers -- David Robley Polls show that 9 out of 6 schizophrenics agree. Today is Setting Orange, the 59th day of Confusion in the YOLD 3175. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I am new to programming. How would I use foreach()to display the entries in the array? You could read TFM which has an example - http://php.net/manual/en/control-structures.foreach.php Cheers -- David Robley Why are you wasting time reading taglines? Today is Setting Orange, the 59th day of Confusion in the YOLD 3175. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: A form and an array
Jason Carson wrote: Jason Carson wrote: Hello everyone, Lets say I have a file called form.php with the following form on it that redirects to index.php when submitted. I would like to take the values of the text fields in the form and put them into an array, then be able to display the values in that array on index.php Does anyone know how I would do that? Here is my form... form action=index.php method=post table tr tdOption1/td tdinput type=text name=option[] //td /tr tr tdOption2/td tdinput type=text name=option[] //td /tr tr td/td tdinput value=submit name=submit type=submit //td /tr /table /table/form You'll find they are already in an array which you can access as $_POST['option'] - from there foreach() should be the next step. Cheers -- David Robley Polls show that 9 out of 6 schizophrenics agree. Today is Setting Orange, the 59th day of Confusion in the YOLD 3175. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I am new to programming. How would I use foreach()to display the entries in the array? You could read TFM which has an example - http://php.net/manual/en/control-structures.foreach.php Cheers -- David Robley Why are you wasting time reading taglines? Today is Setting Orange, the 59th day of Confusion in the YOLD 3175. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php What I currently have is... foreach ($_POST['option'] as $value) { echo Value: $valuebr /\n; } ...but that doesn't work. TFM didn't help me :-( -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: A form and an array
Did you correct the missing double quote in your sending form first? Warren Vail -Original Message- From: Jason Carson [mailto:ja...@jasoncarson.ca] Sent: Thursday, July 23, 2009 9:33 PM To: php-general@lists.php.net Subject: Re: [PHP] Re: A form and an array Jason Carson wrote: Jason Carson wrote: Hello everyone, Lets say I have a file called form.php with the following form on it that redirects to index.php when submitted. I would like to take the values of the text fields in the form and put them into an array, then be able to display the values in that array on index.php Does anyone know how I would do that? Here is my form... form action=index.php method=post table tr tdOption1/td tdinput type=text name=option[] //td /tr tr tdOption2/td tdinput type=text name=option[] //td /tr tr td/td tdinput value=submit name=submit type=submit //td /tr /table /table/form You'll find they are already in an array which you can access as $_POST['option'] - from there foreach() should be the next step. Cheers -- David Robley Polls show that 9 out of 6 schizophrenics agree. Today is Setting Orange, the 59th day of Confusion in the YOLD 3175. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I am new to programming. How would I use foreach()to display the entries in the array? You could read TFM which has an example - http://php.net/manual/en/control-structures.foreach.php Cheers -- David Robley Why are you wasting time reading taglines? Today is Setting Orange, the 59th day of Confusion in the YOLD 3175. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php What I currently have is... foreach ($_POST['option'] as $value) { echo Value: $valuebr /\n; } ...but that doesn't work. TFM didn't help me :-( -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: A form and an array
Yes Did you correct the missing double quote in your sending form first? Warren Vail -Original Message- From: Jason Carson [mailto:ja...@jasoncarson.ca] Sent: Thursday, July 23, 2009 9:33 PM To: php-general@lists.php.net Subject: Re: [PHP] Re: A form and an array Jason Carson wrote: Jason Carson wrote: Hello everyone, Lets say I have a file called form.php with the following form on it that redirects to index.php when submitted. I would like to take the values of the text fields in the form and put them into an array, then be able to display the values in that array on index.php Does anyone know how I would do that? Here is my form... form action=index.php method=post table tr tdOption1/td tdinput type=text name=option[] //td /tr tr tdOption2/td tdinput type=text name=option[] //td /tr tr td/td tdinput value=submit name=submit type=submit //td /tr /table /table/form You'll find they are already in an array which you can access as $_POST['option'] - from there foreach() should be the next step. Cheers -- David Robley Polls show that 9 out of 6 schizophrenics agree. Today is Setting Orange, the 59th day of Confusion in the YOLD 3175. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I am new to programming. How would I use foreach()to display the entries in the array? You could read TFM which has an example - http://php.net/manual/en/control-structures.foreach.php Cheers -- David Robley Why are you wasting time reading taglines? Today is Setting Orange, the 59th day of Confusion in the YOLD 3175. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php What I currently have is... foreach ($_POST['option'] as $value) { echo Value: $valuebr /\n; } ...but that doesn't work. TFM didn't help me :-( -- 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] Mediawiki's url confusion
On Fri, Jul 24, 2009 at 10:28:52AM +0800, Dengxule wrote: Thanks a lot. As far as i know, both methods dealing with urls are WEB-SERVER-TECH. While I was installing mediawiki, i did nothing with the file httpd.conf, no changes made on mod_rewrite. The mediawiki install script cannot do nothing to httpd.conf i think. So i'm confused about how the url-rewriting mechanism is activited. This can also be accomplished by Apache's lookback feature. If it's turned on on the server, Apache will look back through the URL until it finds something which is a file, and then consider the remainder of the URL parameters, which it provides to the file. Thus, http://example.com/index.php/pepperoni/pizza will end up at http://example.com/index.php with pepperoni/pizza as parameter, assuming that pepperoni and pizza are not files/directories and index.php is not a directory. The lookback feature can be turned on in the Apache configuration file, which, on a public server, you have no access to. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: A form and an array
In php.ini turn the display_errors to on. If any error,warn or notice shown,copy them and paste here. So you can tell us what doesn't work. good luck~ 2009/7/24 Jason Carson ja...@jasoncarson.ca Jason Carson wrote: Jason Carson wrote: Hello everyone, Lets say I have a file called form.php with the following form on it that redirects to index.php when submitted. I would like to take the values of the text fields in the form and put them into an array, then be able to display the values in that array on index.php Does anyone know how I would do that? Here is my form... form action=index.php method=post table tr tdOption1/td tdinput type=text name=option[] //td /tr tr tdOption2/td tdinput type=text name=option[] //td /tr tr td/td tdinput value=submit name=submit type=submit //td /tr /table /table/form You'll find they are already in an array which you can access as $_POST['option'] - from there foreach() should be the next step. Cheers -- David Robley Polls show that 9 out of 6 schizophrenics agree. Today is Setting Orange, the 59th day of Confusion in the YOLD 3175. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I am new to programming. How would I use foreach()to display the entries in the array? You could read TFM which has an example - http://php.net/manual/en/control-structures.foreach.php Cheers -- David Robley Why are you wasting time reading taglines? Today is Setting Orange, the 59th day of Confusion in the YOLD 3175. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php What I currently have is... foreach ($_POST['option'] as $value) { echo Value: $valuebr /\n; } ...but that doesn't work. TFM didn't help me :-( -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: A form and an array
I have it working now. I had a comma where a semicolon should have been. Silly error on my part but thanks to everyone who tried to help me. In php.ini turn the display_errors to on. If any error,warn or notice shown,copy them and paste here. So you can tell us what doesn't work. good luck~ 2009/7/24 Jason Carson ja...@jasoncarson.ca Jason Carson wrote: Jason Carson wrote: Hello everyone, Lets say I have a file called form.php with the following form on it that redirects to index.php when submitted. I would like to take the values of the text fields in the form and put them into an array, then be able to display the values in that array on index.php Does anyone know how I would do that? Here is my form... form action=index.php method=post table tr tdOption1/td tdinput type=text name=option[] //td /tr tr tdOption2/td tdinput type=text name=option[] //td /tr tr td/td tdinput value=submit name=submit type=submit //td /tr /table /table/form You'll find they are already in an array which you can access as $_POST['option'] - from there foreach() should be the next step. Cheers -- David Robley Polls show that 9 out of 6 schizophrenics agree. Today is Setting Orange, the 59th day of Confusion in the YOLD 3175. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I am new to programming. How would I use foreach()to display the entries in the array? You could read TFM which has an example - http://php.net/manual/en/control-structures.foreach.php Cheers -- David Robley Why are you wasting time reading taglines? Today is Setting Orange, the 59th day of Confusion in the YOLD 3175. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php What I currently have is... foreach ($_POST['option'] as $value) { echo Value: $valuebr /\n; } ...but that doesn't work. TFM didn't help me :-( -- 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] Mediawiki's url confusion
I think PATHINFO is probably what i'm looking for. Paul mentioned the lookback feature, i think that is or about the same thing. MediaWiki-1.15.1 use the pattern of url for common pages like this : some_path_to_mediawiki/index.php/something , and the 'something' supports even non-english characters. Maybe this kind of usage to transfer params can improve the SEO ? I was trapped in the question how can the MediaWiki scripts affect the apache's behaviour, then finally found out it just takes advantage of the existing FEATURE when i tried this kind of url to my script which var_dump the $_SERVER and saw the pathinfo ... Thank you all, best wishes ~ Deng 2009/7/23 Ford, Mike m.f...@leedsmet.ac.uk -Original Message- From: Paul M Foster [mailto:pa...@quillandmouse.com] Sent: 23 July 2009 06:13 On Thu, Jul 23, 2009 at 11:57:51AM +0800, ?? wrote: But I cannot help myself with the url pattern : /somepath_to_mediawiki/index.php/pagetitle. How can this kind of url be parsed to the file index.php and the pagetitle be parsed as params? Why the web server not go straight into path index.php/ and look for the file named pagetitle ? This type of thing is common for sites using the MVC or Model-View-Controller paradigm. The index.php file is what's called a front controller. A front controller is usually the entrance to all the other pages of a site. URLs like this often take advantage of an Apache feature called mod_rewrite, which tells Apache how to handle URLs which look like this. Or by the pathinfo mechanism, which I believe is also supported by other Web servers, and can work just as well, if it satisfies your requirements, without all the complications of mod_rewrite. 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