Re: Re: [PHP] include
On 20 Nov 2011 at 23:46, Tamara Temple wrote: > 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? I'm looking for confirmation that: include $fn; is an allowed form of the include statement. > 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. Hmmm, I think perhaps I've not made myself clear - sorry about that. At present I'm using AJAX and apache; I'd like to *stop* doing that (and not use another web server, either). In my case, client and server are the same machine - the user's machine. There is a browser window and JavaScript within it which makes the AJAX requests. I just happen to use apache to have a variety of PHP scripts run to provide results back to the browser window. > 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. At present these scripts generally are short-lived, but with some notable exceptions. Hence my exploration of whether I could use websockets instead. -- Cheers -- Tim -- 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 2:56 AM, Tim Streater wrote: > On 20 Nov 2011 at 23:46, Tamara Temple wrote: > >> 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? > > I'm looking for confirmation that: > > include $fn; > > is an allowed form of the include statement. > RTFM [1] example #6 ;) HTH, Tommy [1] http://php.net/function.include -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] include
On 21 Nov 2011 at 11:10, Tommy Pham wrote: > On Mon, Nov 21, 2011 at 2:56 AM, Tim Streater wrote: >> I'm looking for confirmation that: >> >> include $fn; >> >> is an allowed form of the include statement. >> > > RTFM [1] example #6 ;) > [1] http://php.net/function.include Thanks - I missed that one. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP script won't run in the background
On 19 November 2011 14:33, richard gray wrote: > Hi all > > Hope someone can help me with a weird issue I have... > > I am trying to run a php CLI script in the background and it just won't run > - it has a status of Stopped SIGTOU (Trying to write output) - Here are the > details > > OS > Mac OS X Lion 10.7.2 > > PHP > PHP 5.3.6 with Suhosin-Patch (cli) (built: Sep 8 2011 19:34:00) > Copyright (c) 1997-2011 The PHP Group > Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies > > I created a basic script test.php > > > > Here are the results of various tests:- > > Test 1) php -f test.php (Hello world gets displayed) > Test 2) php -f test.php >test.log 2>&1 (Hello world gets put into test.log) > Test 3) php -f test.php >test.log 2>&1 & --- I get [1]+ Stopped(SIGTTOU) > php -f test.php > test.log 2>&1 -- and the job just sits there doing > nothing nothing gets logged however lsof shows the log file is open > > It is something to do with php because a similar shell script gets executed > no problems in the background... > > This has me stumped ... any ideas? > > TIA > Rich > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > I've seen this ... php script.php 1>nul 2>nul Not sure how effective it is. But the code is tagged as a "fire and forget" mechanism. -- Richard Quadling Twitter : EE : Zend : PHPDoc : Fantasy Shopper @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea : fan.sh/6/370 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] include
Tim Streater wrote: > I'm looking for confirmation that: > > include $fn; > > is an allowed form of the include statement. Yes, it is definitely allowed. The syntactic sugar of using parens around the include subject is optional, as it is in other parts of php as well. That said, it's usually better to include the syntactic sugar so as to make future maintenance concerns easier -- there's less chance of a future change to introduce an error if it's clear what things are grouped with what. Much less of a concern in this case, but more of a concern in, say, compound expressions. are all equivalent, because php interpolates variable references in double quoted strings. however is not. > > 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. > > Hmmm, I think perhaps I've not made myself clear - sorry about that. At > present I'm using AJAX and apache; I'd like to *stop* doing that (and not use > another web server, either). In my case, client and server are the same > machine - the user's machine. There is a browser window and JavaScript within > it which makes the AJAX requests. I just happen to use apache to have a > variety of PHP scripts run to provide results back to the browser window. > > > 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. > > At present these scripts generally are short-lived, but with some notable > exceptions. Hence my exploration of whether I could use websockets instead. Ah, okay, I'm not at all familiar with websockets, so I'm going to have to step out of this. Good luck with it! -- 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:59 PM, Geoff Shang wrote: > 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. > > 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 > __ Geoff: Hmmm, granted your output is different than mine. But I think there is something else beside timezones going on here, but I could be wrong. My server is set to America New York (+5 hours) and uses PHP version 5.2.17 Let's consider this -- you are in a different time zone than me, right? You said UTC and mine is America New York. As such you claim is that your strtotime() function will return a different result for you as compared to me because of the time zone differences, right? If so, then tell me why I can take both sites (your and mine) and click the Submit buttons at the same time and the forms will report back the exact same number of elapsed seconds. Try it (you got to be quick): http://www.webbytedd.com//strtotime/index.php http://quitelikely.com/~geoff/strtotime/index.php Why is that? By what you said, shouldn't the reports be offset (+5 hours) by the local timezone differences? What am I not understanding here? 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: [PHP] PHP script won't run in the background
On Sat, Nov 19, 2011 at 11:27 PM, richard gray wrote: > >> Laruence, while that may be a helpful answer to a few people in the know, I think a clue is better, leave some space for the people to dance. :) >> just replying back with a single line like that isn't really going to help >> the people who are having this problem. At least explain why you suggested >> that, or what it does for those on the list that don't know, especially as >> it's not a PHP thing, it's a Unix command thing. >> >> Richard, some more info on the command Laruence mentioned can be found at >> http://docstore.mik.ua/orelly/unix/upt/ch12_07.htm which explains it in more >> detail. >> > not sure this is relevant as my script is not trying to write to the > terminal the >test.log 2>&1 is sending stdout and stderr to the log file not > the tty... did you run php with readline? try run the script without php-readline. thanks > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Laruence Xinchen Hui http://www.laruence.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php