[PHP] Re: bg execution
[EMAIL PROTECTED] (Martin Helie) writes: > Hello, > > I need to start a php-based socket server that doesn't die if the client > closes their browser window. > > Is there another (maybe cleaner) method to accomplish this, other than > > exec('bash -c "exec nohup setsid php server.php > /dev/null 2>&1 &"'); I haven't had a need for something like this myself, but I think the ignore_user_abourt() function is what you need: http://php.net/manual/en/function.ignore-user-abort.php -- Martin Geisler My GnuPG Key: 0xF7F6B57B PHP EXIF Library | PhpWeather | PhpShell http://pel.sf.net/| http://phpweather.net/ | http://gimpster.com/ Read/write EXIF data | Show current weather| A shell in a browser -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Newbie error with cookies and headers already declared
[EMAIL PROTECTED] (Chris W. Parker) writes: > 2. you cannot create/write a session value after you send any html > output to the client. That's not entirely true --- you just have to call session_start() before any HTML output is sent to the browser, for session_start() must be able to set the session cookie (if using session cookies that it). The very first example here illustrates this: http://php.net/session-start There the session_start() is called, then some output is sent to the browser, and later the three session variables 'favcolor', 'animal', and 'time' is set. The session variables can be set and updated at any time because this only associates data with the session on the server side. -- Martin Geisler My GnuPG Key: 0xF7F6B57B PHP EXIF Library | PhpWeather | PhpShell http://pel.sf.net/| http://phpweather.net/ | http://gimpster.com/ Read/write EXIF data | Show current weather| A shell in a browser -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Random Record Retrieval
[EMAIL PROTECTED] (Robb Kerr) writes: > How's that for alliteration in a subject line? Very nice! :-) > [...] And, if this is the best way to go, unfortunately I don't > know how to write a random number generator in PHP so would > appreciate any help. Your idea sounds good, and luckily you don't have to build your own random generator, behold: http://php.net/rand Then call rand() with two arguments: the minimum and maximum ID, and it will give you a random integer back between those two numbers. You could also opt to have MySQL make the random number for you, and then do a query like SELECT * FROM table ORDER BY RAND() LIMIT 1; Then you wont have to deal with figuring out the number of rows in the table as you would in the PHP case. You can also increse the limit to, say, 3 and then show three random quotes on your pages. See http://dev.mysql.com/doc/mysql/en/Mathematical_functions.html#IDX1363 for a description of RAND() in MySQL. -- Martin Geisler My GnuPG Key: 0xF7F6B57B PHP EXIF Library | PhpWeather | PhpShell http://pel.sf.net/| http://phpweather.net/ | http://gimpster.com/ Read/write EXIF data | Show current weather| A shell in a browser -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sessions
[EMAIL PROTECTED] (Richard Davey) writes: > Perhaps - imagine how many scripts out there would break if it did > :) (not that I'd care, I code exclusively with E_ALL) > > Actually, doesn't PHP5 do this? The following test gives just one 'Notice: Use of undefined constant foo...' message when I run it with PHP5: 'bar'); echo $array[foo] . "\n"; error_reporting(E_ALL); echo $array[foo] . "\n"; ?> -- Martin Geisler My GnuPG Key: 0xF7F6B57B PHP EXIF Library | PhpWeather | PhpShell http://pel.sf.net/| http://phpweather.net/ | http://gimpster.com/ Read/write EXIF data | Show current weather| A shell in a browser -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: DOM XML output whitespace
[EMAIL PROTECTED] (Dan Phiffer) writes: > I'm using PHP 5 these days, so I guess I'm looking for some way to > tell a DomDocument to prettify its save() output. I don't remember any more where I found this, but with formatOutput = true; ?> you get what you ask for: formatted output. -- Martin Geisler My GnuPG Key: 0xF7F6B57B PHP EXIF Library | PhpWeather | PhpShell http://pel.sf.net/| http://phpweather.net/ | http://gimpster.com/ Read/write EXIF data | Show current weather| A shell in a browser -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Problem with number_format
[EMAIL PROTECTED] writes: > please suppose PHP 4.3.2 and $number=502,3550 > > number_format($number,2,'.',' ') returns 502.36. > > It seems ok, but if $number=253,0650 > > number_format($number,2,'.',' ') returns 253.06 instead of 253.07. My PHP manual (from a Debian package) has the following note on the page for round(): Caution When rounding on exact halves round() rounds down on evens and up on odds. If you want to always force it in one direction on a .5 (or .05 in your case) add or substract a tiny fuzz factor. The reason behind rounding half the values down and the other half up is to avoid the classical banking problem where if you always rounded down you would be stealing money from your customers, or if you always rounded up you would end up over time losing money. By averaging it out through evens and odds you statistically break even. -- Martin Geisler My GnuPG Key: 0xF7F6B57B PHP EXIF Library | PhpWeather | PhpShell http://pel.sf.net/| http://phpweather.net/ | http://gimpster.com/ Read/write EXIF data | Show current weather| A shell in a browser -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Simplistic PHP tutorial
[EMAIL PROTECTED] (Neal) writes: > Can anyone recommend a simple, hand-holding, introductory tutorial > suitable for someone with no programming experience to speak of? I have a tutorial online here which is supposed to be pretty basic: http://gimpster.com/wiki/PhpTutorial It was written a long time ago so it doesn't include the newer PHP4 stuff. -- Martin Geisler My GnuPG Key: 0xF7F6B57B PHP EXIF Library | PhpWeather | PhpShell http://pel.sf.net/| http://phpweather.net/ | http://gimpster.com/ Read/write EXIF data | Show current weather| A shell in a browser -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Problem with number_format
[EMAIL PROTECTED] (Curt Zirzow) writes: > * Thus wrote Martin Geisler ([EMAIL PROTECTED]): >> >> Caution >> >> When rounding on exact halves round() rounds down on evens and up >> on odds. [...] > > This is a documentation error. And is not on the current > documentation. Indeed you're right, sorry about that. -- Martin Geisler My GnuPG Key: 0xF7F6B57B PHP EXIF Library | PhpWeather | PhpShell http://pel.sf.net/| http://phpweather.net/ | http://gimpster.com/ Read/write EXIF data | Show current weather| A shell in a browser -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php