php file itself
2008年08月08日 (php)
command
% echo '<?php echo $_SERVER["PHP_SELF"]."\\n"; ?>' > test.php % cat test.php <?php echo $_SERVER["PHP_SELF"]."\n"; ?> % php test.php test.php %
note
一昔前の記述方法,$PHP_SELFだけだとうまくいかない.
PR
like shell script
2008年08月05日 (php)
source
#!/usr/local/bin/php <?php echo("php like shell script\n"); ?>
sample execution
% vim likeshellscript.php % chmod 744 likeshellscript.php % ./likeshellscript.php php like shell script %
simple access counter
2008年08月05日 (php)
source
<html> <head> <title>simple access counter</title> </head> <body> <?php $f=fopen("count.txt","r+"); $count=fgets($f,10); $count=(int)$count; $count++; rewind($f); fputs($f,$count); fclose($f); echo("welcome to my web. you are #$count visiter.\n"); ?> </body> </html>
command
% vim simpleaccesscounter.php % echo 0 > count.txt % chmod 666 count.txt
| HOME |