Re: [PHP] Add lines to a text file
On Wednesday, Dec 11, 2002, at 13:36 US/Pacific, Antti wrote: Thanks it works. I forgot to say that i need to add a new line to that file. Now it puts all the stuff at the same line. How do I make it to add lines? Use fputs with the string ending with a \n, as in: $xmlfp = fopen($theXMLFile, a); fputs($xmlfp, ?xml version=\1.0\ encoding=\ISO-8869-1\ ?\n); fputs($xmlfp, design type=\developer\\n); . fputs($xmlfp, /design\n); fclose($xmlfp); terveisia, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] echo vs printf
As I understand it, echo is not a function it's a language something or other, supposedly it runs slightly faster than print given the same output. ?php class xTimer{ var $time_start; var $time_delta; function Start(){ $this-time_start = $this-GetMicroTime(); } function Stop(){ $time_end = $this-GetMicroTime(); $this-time_delta = $time_end - $this-time_start; return $this-time_delta; } function GetMicroTime(){ list($usec, $sec) = explode( , microtime()); return ((float)$usec + (float)$sec); } } print echo vs print testbr\n; $string = foo ; $iter = 100; $t = new xTimer; $t-Start(); for($i = 0; $i $iter; $i++){ print $string; } $print_time = $t-Stop(); $t-Start(); for($i=0; $i $iter; $i++){ echo $string; } $echo_time = $t-Stop(); print \nbrprint printing $iter times: $print_timebr\n; print \nbrecho printing $iter times: $echo_timebr\n; ? Results: Test1: print printing 100 times: 2.829174041748 echo printing 100 times: 3.683454990387 Test2: print printing 100 times: 3.131462931633 echo printing 100 times: 2.8942189216614 Test3: print printing 100 times: 5.127711057663 echo printing 100 times: 5.5264019966125 HW, Dell rackmount Server, dual CPU running Linux 2.2.16. --Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Variable name declarations?
function sum_array( $input_array ) { var $index; var $sum = 0; for( $index = 0; $index count( $input_array ); $index++ ) $sum += $input_array[ $index ]; return $sum; } The array variable issue has indeed bitten me a couple of times, so now all my arrays are called $something_arr. It would nice to introduce more runtime checking of array types and complaints in case non-array values are used in functions. But otherwise the strong type checking will just cause more problems and more overhead with calls. I don't know if the example above will help that much, but you could already write similar code in functions to make sure that the values are declared on top, to make things clearer. --Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Re: Rename a File?
rename(moo.php, foo.php); Also, works cross-platform. In most cases try to find a function that is part of PHP rather than using the shell, especially if you are interested in making sure the code works across platforms. There's also most likely a performance hit when starting a shell versus issuing system level calls. --Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Re: Warning: mail() is not supported in this PHP build
Just I have another question, does anyone know where PHP puts everything when it installs? I keep recompiling PHP and Apache, and every time I run phpinfo() it still has the original build date. I tried deleting: If installed as RPM package: $ rpm -ql php This gives the paths to the installed php files. If installed by hand, then try to do a find: $find / -name '*php*' -print That should catch a lot related to php, php.ini, php directories, the php binary, a possible libphp4.so apache module, and so forth. --Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Code Examples for Job Interview
You could also bring with you someone else's code :-). Frankly speaking, if I interview programming candidates, I define a couple of practical problems to see what kind of background they have, how to solve it, the thinking process is as important as the final result. If someone gives a stock answer without going through analysis why this is the best, then it shows (at least in my eyes) that they have not done a lot of coding, as seldom the first answer is the best one. Also, if the solution hints at code reuse, classes, and so forth, then that shows they are thinking about maintenance of code. If you bring your own samples, anything that shows that you are thinking about maintenance and code reusability would be a big plus, as well as if there's clearly an architecture behind the whole solution -- even better a scaleable one. Anyway, hope this helps, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Latest documentation in PDF format?
Hi, I saw that the PHP documents in PDF format are temporary unavailable at: http://www.php.net/docs.php Now, I do have a working Acrobat 4.0 version back home, any interest if I built the HTML versions to PDF format, or is there something else I don't know about, i.e. an automated backend for building the PDF documents from an original source? --Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] $PHP_SELF name space?
Hi, is there something silly I'm doing (latest PHP 4.0.5), when this does not work at all: --- class xCrumbs { function Render(){ echo $PHP_SELF; } } $crumbs = new xCrumbs(); $crumbs-Render(); while echo $PHP_SELF; works just fine? Or something with name spaces and when $PHP_SELF is activated? Thx, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Need recommendation: good user management system (PHP/MySQL)
Stuff I'm using here, could be better, but it's a start: --- For MySQL (or other SQL database): cat create_access_tbl.sql /* --- FBI Access Control Database Format -- * This is the proposed format for the access control database. * Use mysql to recreate the database if needed. * * MySQL-Dump * Database: access_control * Table structure for table 'access_control' * This assumes that there's an existing MySQL database. * Use: * $ mysql -u admin -pthePassword the_database create_access.tbl.sql */ CREATE TABLE access_control ( primary_key MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT, user VARCHAR(50) NOT NULL, password VARCHAR(30) NOT NULL, userlevel TINYINT(3), email varchar(50) NOT NULL, PRIMARY KEY (primary_key), KEY (user) ); --- class AccessControl { function Verify($name, $passwd){ if ($DB = mysql_connect(localhost, the_login, the_password)){ if($DEBUG){ echo Connection to Database OK...br\n; } } else { echo Database Connection Errorbr; echo Failed to Connect to Databasebr; return null; } mysql_select_db(access_control) or die(Database connection failed [fbi] . mysql_er ror()); if($DEBUG){ echo Database access_control selected...br\n; } $result = mysql_query(SELECT * FROM access_control WHERE user = '$name' AND password = '$passwd') or die (Query failed: . mysql_error()); if($row = mysql_fetch_array($result)){ /* the right person is in the database, return the email address as we will need it later */ return $row[email]; } else{ return null; /* nope */ } } } --- Use: $acl = new AccessControl(); $email = $acl-Verify($name, $password); if($email == null){ // let the end user know about it, or something else } else { // let the end user continue } --- Then pass in the $name and $password from a previous screen in forms of an input field, either through a login screen, or then if there's a chain of screens, continue passing this along with a hidden field. This means anyone trying to get to the further screens will be blocked as the right login and passwd is not passed around. Yes I know, I could have used sessions, but I think this was more approprate in case cookies are disabled, and otherwise just felt it was more appropriate to carry the state around. Anyway, sure there are holes and such, but hope this helps, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] PHP/OCI8 design for persistent connection tuning
My first instinct is to run a second apache process on a separate port or on another IP, that would be tuned for flatfiles. It'd mean that I'd have to code all my scripts to tell it to look for www.somewhere.com:88/banner.gif, which is fine since this is a new architecture. Yes, if you have images, put them on a separate image server with a tuned http server that is just optimized for returning material quickly -- you could experiment around with various web server solutions to find the fastest server out there. Or then put the image server on the same HW and a separate port, as you mentioned, that way you get threading happening. --Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]