Re: [PHP] Impossibility of reading php.ini
A look at the Apache log would have avoid opening this thread. - a syntax error in php.ini : an uncommented comment line !! - an older version of the ZendDebugger Now everything is fine. It's work !! Le 19/11/2011 20:55, Alain Chautar a écrit : Yes I change the right one : /etc/php5/apache2/php.ini .It fit with "Loaded Configuration File" in phpinfo(). This the reason I get confused. Le 19/11/2011 20:26, Matijn Woudt a écrit : On Sat, Nov 19, 2011 at 7:23 PM, Alain Chautar wrote: Hello I am a newbie of this list. So if this topic as a known answer, I apologize. I use a brand new Debian Squeeze with PHP5.3.3-7+Squeeze3 as a web server. All my web sites are OK. For my needs I have to change values in the php.ini . The way I proceed : I change values -> I save php.ini -> I restart Apache2 -> I verify with phpinfo() or ini_get ... My phpinfo() can be read at 213.41.212.98/test.php and my php.ini is join to this mail. If somebody have an idea ??? Thanks. Are you sure you changed the correct php.ini file? In my debian there is one for the CLI and one for Apache, eg: cd /etc&& find -iname "php.ini" ./php5/cli/php.ini ./php5/apache2/php.ini where ofcourse only the last one affects your website. Matijn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] include
On Sat, Nov 19, 2011 at 2:16 PM, Tim Streater wrote: > At the moment I'm using an instance of apache to run PHP scripts, as and when > required via AJAX. Having got some understanding of web sockets, I'm minded > to look at having a small server to execute these functions as required. The > scripts, some 50 or so, are only about 300kbytes of source code, which seems > small enough that it could all be loaded with include, as in: > > $fn = 'wiggy.php'; > include $fn; > ?> > > This appears to work although I couldn't see it documented. > > I'd also like to be able to replace a module without restarting the server. I > couldn't see a way to drop an included file, do I therefore take it that > there is none? Failing that, is there a good way to dynamically replace parts > of a PHP program, possibly using runkit? > > -- > Cheers -- Tim > > Tim, I think you're approaching this the wrong way. 1) have a clear understanding of PHP - syntax, capabilities, etc. 2) have a clear understand of what you're intending to do - application's function/purpose, features, manageability, expandability, portability, etc... 3) understand design patterns What your asking is practically impossible in any programming language akin to 'how to un-import packages in Java' or 'how to un-using namespace in C#'. If you don't want to use it, don't include it ;) If this is running as web app, you can use header [1] and pass the criteria for next phase of the operation as URL parameters. But doing this is going to kill the server side with too many unnecessary round trips. Which clearly demonstrates point 2 and 3. You should look into Interfaces, and Abstract under OOP [2]. HTH, Tommy [1] http://php.net/function.header [2] http://php.net/language.oop5 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sniping on the List
On Sat, 19 Nov 2011, Tedd Sperling wrote: My observations are demonstrated here: http://www.webbytedd.com//strtotime/index.php this code would IMHO be more useful if it also displayed time, not just date. It's also not clear what timezone you're using, as it's not set as far as I can see. Please note that regardless of time zone, the strtotime() function works (or at least it does for me) such that: If you enter '-1', the function will report back Todays Date with current seconds. Note there is no difference between entering 'Today' or '-1'. This is not what your code shows. String Given: -1 Seconds Computed from String: 1321805103 Date from Seconds Computed: 20 November, 2011 : Sunday ___ Current Time (seconds): 1321819503 Current Date: 20 November, 2011 : Sunday This is a difference of 14400 seconds or 4 hours. String Given: today Seconds Computed from String: 1321765200 Date from Seconds Computed: 20 November, 2011 : Sunday ___ Current Time (seconds): 1321819877 Current Date: 20 November, 2011 : Sunday This is a much larger difference. 'today' is meant to return the same as 'today 00:00:00'. I know it used not to, it was a PHP bug awhile back... which begs the question, which PHP version are you using? If you enter '0', the function will report back December, 31, 1969. You'll also notice that the value of seconds computed from string is blank (i.e. not 0). This is because strtotime() doesn't know what to do with a value of '0'. Whether it should or not is probably a phillosophical debate. If you enter nothing (i.e., null), then it reports back December, 31, 1969. It does, but we dont' know exactly when this is because your script doesn't show time. It could be actually returning a 0 timestamp. We can force your script to show us what 0 time is according to its timezone by entering an absolute date including UTC offset. String Given: 1 January 1970 + Seconds Computed from String: 0 Date from Seconds Computed: 31 December, 1969 : Wednesday ___ So your script shows 31/12/1969 for the epoch, so we dont' know if the null value is the epoch or before. To further prove my point, witness the number of seconds calculated from 1 January 1970 in your script's timezone: String Given: 1 January 1970 Seconds Computed from String: 18000 Date from Seconds Computed: 1 January, 1970 : Thursday ___ This means your script is using a timezone of UTC -0500 (US Eastern). So any time within the first 5 hours of the epoch will show as being in 1969. To avoid this, explicitly set your script to use UTC. Or use US Eastern but be up front about the fact that your'e doing this. It's clear (and by definition) that unix zero time (i.e., 00:00:00) happened in 1970. It's also clear that time before unix zero happened before 1970 (i.e., 'December 31, 1969'). As such, null (and not the string 'null' as stated my someone else, duh) should come back as "undefined" OR "December, 31, 1969". It doesn't for me, using either PHP 5.2.6 or 5.3.3. php -r 'echo date ("r", strtotime (""));' Thu, 01 Jan 1970 00:00:00 + Furthermore, the string '-1' should default to '-1 second' instead of being the same as if I entered 'Today'. Apart from the fact that for me at least, strtotime ("today") returns today at midnight, whereas strtotime ("-1") seems to return something else (time() + 3600 on boxes set to UTC, time() + 10800 on my box set to local time in Israel), strtotime is meant to turn textual representations of time into a unix timestamp. Surely the meaning of "-1" is at the very least ambiguous, and the fact that it returns anything is surprising. Now, where are my observations wrong? The code is shown in the demo. To summarise, your observations are wrong because they do not take timezone into account and do not show the time, only the date. And some of your observations as given above do not match what your script outputs. Geoff. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Parsing the From field
On Sat, 19 Nov 2011, Ron Piggott wrote: Also the formatting of the from field changes in various e-mail programs: From: Ron Piggott From: "Ron Piggott" From: ron.pigg...@actsministries.org From: I've also seen: Piggott, Ron And that's before you get to people who only use their first name and people who use some kind of alias. I think you did well to abandon this. Geoff. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sniping on the List
On Nov 20, 2011, at 4:00 PM, Geoff Shang wrote: > On Sat, 19 Nov 2011, Tedd Sperling wrote: > >> Now, where are my observations wrong? The code is shown in the demo. > > To summarise, your observations are wrong because they do not take timezone > into account and do not show the time, only the date. And some of your > observations as given above do not match what your script outputs. > > Geoff. > Geof: I appreciate your time and comments. However, you missed the point I was trying to make, which does not have anything to do with timezones. If you copy my code and place it on any server in the world, you'll observe the same results as I did. You touched on my point with: > You'll also notice that the value of seconds computed from string is blank > (i.e. not 0). This is because strtotime() doesn't know what to do with a > value of '0'. Whether it should or not is probably a phillosophical debate. But you did not contribute to which side of the debate would you side. My prior opinion was that 0 should return 'Jan 1, 1970'. However, Stuart pointed out a flaw in my code. You see, I was assuming that using the return from strtotime(0) in the getdate() function would return the correct date, but this was a cascade error. I have not investigated this further. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: [PHP] include
On 20 Nov 2011 at 10:36, Tommy Pham wrote: > I think you're approaching this the wrong way. > 1) have a clear understanding of PHP - syntax, capabilities, etc. That's what I'm doing - gathering information about bits of PHP that I've not used (or not used very much) before to see how my new setup could be structured. > 2) have a clear understand of what you're intending to do - > application's function/purpose, features, manageability, > expandability, portability, etc... I have a clear idea about *that*. I want to figure out if it's possible to use web sockets with a small server written in PHP to replace my current structure of ajax + apache + processes (which I suppose it forks). I see these benefits: 1) possible benefit - presumably when an ajax request arrives, a new process is started and so PHP has to be loaded and initialised each time. But perhaps this is in some way optimised so the PHP process is left running and apache then just tells it to read/execute a new script. 2) Definite benefit - when a browser makes an ajax request to run a script, it gets no information back until the script completes. Then it gets all of it. I have a couple of unsatisfactory workarounds for that in my existing structure. Websockets appears to offer a way for the browser to receive timely information. > 3) understand design patterns I don't know what this means. > What your asking is practically impossible in any programming language > akin to 'how to un-import packages in Java' or 'how to un-using > namespace in C#'. If you don't want to use it, don't include it ;) I do want to use it but would like to be able to replace it with a newer version. If there is no way to do this then that is a data point. And here's another question. Can a child forked by pcntl_fork() use a socket that the parent obtained? Reading the socket stuff in the PHP doc, there are a number of user-supplied notes hinting this might be problematic. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sniping on the List
On Sun, 20 Nov 2011, Tedd Sperling wrote: I appreciate your time and comments. However, you missed the point I was trying to make, which does not have anything to do with timezones. If you copy my code and place it on any server in the world, you'll observe the same results as I did. NO I won't, and timezones do matter. I've copied your code to http://quitelikely.com/~geoff/strtotime/ Sorry if any of the visuals are mangled, I had to massage the script a little to pullin the header and footer, and I downloaded your logo, but I didn't go and dig out your CSS or javascript. This server is set to UTC and uses PHP 5.2.6. Lets skip right to your point. From your script on your server: String Given: null Seconds Computed from String: null Date from Seconds Computed: 31 December, 1969 : Wednesday ___ From the script on my server: String Given: null Seconds Computed from String: null Date from Seconds Computed: 1 January, 1970 : Thursday __ You touched on my point with: You'll also notice that the value of seconds computed from string is blank (i.e. not 0). This is because strtotime() doesn't know what to do with a value of '0'. Whether it should or not is probably a phillosophical debate. But you did not contribute to which side of the debate would you side. I didn't, because the debate was on whether or not NULL == Wednesday, not whether or not strtotime("0") should return 0. I agree there's a good case for it doing so, you could file a bug if you feel strongly about it. My prior opinion was that 0 should return 'Jan 1, 1970'. However, Stuart pointed out a flaw in my code. You see, I was assuming that using the return from strtotime(0) in the getdate() function would return the correct date, but this was a cascade error. As I think I mentioned before, using strtotime at all is the problem, as we are talking about null as a concept, not "null" the alphabetical string. Since null is nominally a numerical value, we can pass it directly as a timestamp. php -r 'echo date("r", null);' Thu, 01 Jan 1970 00:00:00 + Geoff. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: [PHP] include
On Mon, Nov 21, 2011 at 3:34 AM, Tim Streater wrote: > On 20 Nov 2011 at 10:36, Tommy Pham wrote: > > > I think you're approaching this the wrong way. > > 1) have a clear understanding of PHP - syntax, capabilities, etc. > > That's what I'm doing - gathering information about bits of PHP that I've > not used (or not used very much) before to see how my new setup could be > structured. > > > 2) have a clear understand of what you're intending to do - > > application's function/purpose, features, manageability, > > expandability, portability, etc... > > I have a clear idea about *that*. I want to figure out if it's possible to > use web sockets with a small server written in PHP to replace my current > structure of ajax + apache + processes (which I suppose it forks). I see > these benefits: > > 1) possible benefit - presumably when an ajax request arrives, a new > process is started and so PHP has to be loaded and initialised each time. > But perhaps this is in some way optimised so the PHP process is left > running and apache then just tells it to read/execute a new script. > Did you check http://php-fpm.org/ > > 2) Definite benefit - when a browser makes an ajax request to run a > script, it gets no information back until the script completes. Then it > gets all of it. I have a couple of unsatisfactory workarounds for that in > my existing structure. Websockets appears to offer a way for the browser to > receive timely information. > > > 3) understand design patterns > > I don't know what this means. > > > What your asking is practically impossible in any programming language > > akin to 'how to un-import packages in Java' or 'how to un-using > > namespace in C#'. If you don't want to use it, don't include it ;) > > I do want to use it but would like to be able to replace it with a newer > version. If there is no way to do this then that is a data point. > > And here's another question. Can a child forked by pcntl_fork() use a > socket that the parent obtained? Reading the socket stuff in the PHP doc, > there are a number of user-supplied notes hinting this might be problematic. > > -- > Cheers -- Tim > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- Shiplu Mokadd.im Follow me, http://twitter.com/shiplu Innovation distinguishes between follower and leader
Re: [PHP] include
Tim Streater wrote: > At the moment I'm using an instance of apache to run PHP scripts, as > and when required via AJAX. Having got some understanding of web > sockets, I'm minded to look at having a small server to execute these > functions as required. The scripts, some 50 or so, are only about > 300kbytes of source code, which seems small enough that it could all > be loaded with include, as in: > > $fn = 'wiggy.php'; > include $fn; > ?> > > This appears to work although I couldn't see it documented. I'm really not sure what you're looking for here -- that is pretty standard php practice to load php files with include -- what were you expecting here? While it's certainly possible to rig up something using sockets, I don't think that's how AJAX works, and you'd need a JS library that did. As an alternative, can you set up a lightweight web server like lighttpd and fastcgi on your host machine? This should give you the speed and flexibility without incurring the overhead of loading everything into mod_php under apache. The alternate server would listen on a different port and dispatch fastcgi to deal with the php scripts. As well, you could run fastcgi from apache to dispatch the smaller scripts if you didn't want another web server running, although in practice this hasn't proven to be an issue for me. > I'd also like to be able to replace a module without restarting the > server. I couldn't see a way to drop an included file, do I therefore > take it that there is none? Failing that, is there a good way to > dynamically replace parts of a PHP program, possibly using runkit? Generally, you should only really need to dynamically replace parts of a long-running program if you don't want to restart it. However, php scripts are not long-running programs in general, unlike the apache server itself, for example, and certainly if the php scripts are running under apache, they will be time- and space-limited by whatever is set in the php.ini file. If these little scripts are merely responding to AJAX requests, they should be really short-lived. OTOH, if you do have a need to replace an include file, you can include it again unless you use something like "include_once" or "require_once". Otherwise, the bare "include" and "require" commands will merrily go ahead and re-include the file. What you really need to watch out for is dealing with initialization of variables in the include file, and if what you're including are classes that the previous version has objects out for, what happens then is going to be pretty strange. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: [PHP] include
On Sun, Nov 20, 2011 at 1:34 PM, Tim Streater wrote: > On 20 Nov 2011 at 10:36, Tommy Pham wrote: > >> I think you're approaching this the wrong way. >> 1) have a clear understanding of PHP - syntax, capabilities, etc. > > That's what I'm doing - gathering information about bits of PHP that I've not > used (or not used very much) before to see how my new setup could be > structured. > That's a good starting point. >> 2) have a clear understand of what you're intending to do - >> application's function/purpose, features, manageability, >> expandability, portability, etc... > > I have a clear idea about *that*. I want to figure out if it's possible to > use web sockets with a small server written in PHP to replace my current > structure of ajax + apache + processes (which I suppose it forks). I see > these benefits: > > 1) possible benefit - presumably when an ajax request arrives, a new process > is started and so PHP has to be loaded and initialised each time. But perhaps > this is in some way optimised so the PHP process is left running and apache > then just tells it to read/execute a new script. > > 2) Definite benefit - when a browser makes an ajax request to run a script, > it gets no information back until the script completes. Then it gets all of > it. I have a couple of unsatisfactory workarounds for that in my existing > structure. Websockets appears to offer a way for the browser to receive > timely information. > You didn't understand my 2nd point completely. The 2nd point starts with what function/purpose does the app provide such as is it an e-commerce, CMS, forum, etc... What you're talking about is the process(es) which facilitate(s) the application's functions ie: "there's more than one way to skin the cat" - so to speak. Which is part of manageability, portability, expandability (ie: scaling to clusters, ease of 3rd party plugins, etc), etc >> 3) understand design patterns > > I don't know what this means. > Google "programming design patterns" >> What your asking is practically impossible in any programming language >> akin to 'how to un-import packages in Java' or 'how to un-using >> namespace in C#'. If you don't want to use it, don't include it ;) > > I do want to use it but would like to be able to replace it with a newer > version. If there is no way to do this then that is a data point. > That's why I suggested you read up regarding OOP, including Interface and Abstracts. In OOP, you define and guaranteed certain functionalities with Interfaces - hence the term API (Application Programming Interface) - but you pass a super/parent class or any of its sub/child classes, implement those interface(s), to do the work needed as how you want things done based on certain criteria. Classic example: 1) connect to db 2) execute query 3) fetch results 4) process results 5) close connection given those 5 above steps, there are many ways to proceed about it. Which way you choose depends on my 2nd point. In the past, the standard practice was using client library such as MySQL or MySQLi, especially prior to PHP5. Now it's done via PDO or other data abstraction layer, including ORM depending on a lot of things: experience, skills, knowledge, project dead line, personal preference/style, best coding practices, and lazyness in that given moment - not particularly in those order either. > And here's another question. Can a child forked by pcntl_fork() use a socket > that the parent obtained? Reading the socket stuff in the PHP doc, there are > a number of user-supplied notes hinting this might be problematic. > > -- > Cheers -- Tim > HTH, Tommy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: [PHP] include
On Sun, Nov 20, 2011 at 4:44 PM, Tommy Pham wrote: > On Sun, Nov 20, 2011 at 1:34 PM, Tim Streater wrote: >> On 20 Nov 2011 at 10:36, Tommy Pham wrote: >> >> And here's another question. Can a child forked by pcntl_fork() use a socket >> that the parent obtained? Reading the socket stuff in the PHP doc, there are >> a number of user-supplied notes hinting this might be problematic. >> >> -- >> Cheers -- Tim >> > Forgot to address this in my previous e-mail because I was cooking while trying to read/reply my e-mails. Anyway, if I'm not mistaken, what you're trying to do is making a threaded application. PHP does not support threads currently. PHP and threads has been a heated discussion on this list in the past. You're welcome to search the archives. [1] HTH, Tommy [1] http://marc.info/?l=php-general -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php