php »ù´¡±Ê¼Ç variables
/***************************by
garcon1986********************************/
<?php
// variable name is sensitive
$var = "sjg";
$Var = "wl";
echo $var.' loves '.$Var.'<br>';
echo "$var, $Var<p>";
//naming conventions for variables
//$4site = 'not yet'; // invalid; starts with a number
$_4site = 'not yet'; // valid; starts with an underscore
$täyte = 'mansikka'; // valid; 'ä§ is (Extended) ASCII 228.
echo $_4site.'<br>';
echo $täyte.'<p>';
// pass the address
$ref1 = 'ref1';
$ref2 = &$ref1;
echo $ref1.'<br>'; //ref1
echo $ref2.'<br>'; //ref1
$ref2 = "My name is $ref2";
echo $ref1.'<br>'; //ref1
echo $ref2.'<p>'; //ref1
//$ref2 = &(24*7); //Invalid reference.
function test1()
{
return 25;
}
//$bar = &test(); // Invalid reference.
//global scope ;
$a1 = 1; /* global scope */
function test2()
{
$a1 = 2; // local variable
echo $a1.'<br>'; /* reference to local scope variable */
}
test2();
echo $a1.'<br>'; // global variable
//local scope
$a2 = 3;
$b2 = 4;
function Sum2(){
global $a2, $b2;
$b2 = $a2 + $b2;
}
Sum2();
echo $b2.'<p>';
//static variable
function test3(){
static $a=0;
echo $a;
$a++;
}
test3();
echo '<br>';
test3();
echo '<br>';
test3();
echo '<br>';
test3();
echo '<br>';
test3();
echo '<p>';
//global variable and static variable
function test_global_ref(){
global $obj;
$obj = &new stdClass;
}
function test_global_noref(){
global $obj;
$obj = new stdClass;
}
test_global_ref();
var_dump($obj);
echo '<br>';
test_global_noref();
var_dump($obj);
echo '<p>';
// variable variables
$a3 = 'hello';
$$a3 = 'world';
echo "$a3 ${$a3}"."<br>";
echo "$a3 $hello"."<p>";
?>
Ïà¹ØÎĵµ£º
»¹ÊÇ
²¿ÃÅÎÞÁĵĿ¼Ì⣬²»¹ýÕâ´Î¿¼µÄÊÇ PHP
µÄÄÜÁ¦¡£ÌâÄ¿ÈçÏ£º
¸øÄãÁ½¸ö·Ö±ðÓÐ 5000 ¸öÔªËصÄÊý×飬¼ÆËãËûÃǵIJ
-- ˵°×ÁËÒ²¾ÍÊÇÓà PHP ºÍÄãÈÏΪ×îºÃµÄË㷨ʵÏÖ array_diff µÄËã·¨¡£
³õ´Î½Óµ½Õâ¸öÌâÄ¿£¬ÎÒ·¢ÏÖÕâ·Ç³£µÄ¼òµ¥£¬
ÓÚÊÇ°´ÕÕÒÔÍùµÄ¾Ñé“Ëæ±ã”дÁËÒ»¸ö£º
function array_diff($array_1, $ ......
ÔÎÄÁ´½Ó£ºhttp://www.phpdo.net/index.php/2010/02/11/1-14/
PHPÖлñµÃÈÕÆÚʱ¼äÐÅÏ¢µÄº¯Êý——Getdate
ʱ¼ä´Á:°üº¬ÁË´ÓunixмÍÔª£¨1970Äê1ÔÂ1 ÈÕÁãʱ£©µ½¸ø¶¨Ê±¼äµÄÃëÊý£¬ÊÇÒ»¸ö³¤ÕûÊý¡£
Getdateº¯Êý¾ÍÊÇÓÃÀ´»ñµÃµ±Ç°Ê±¼ä£¬»òÕßÓÃÀ´·ÖÎöʱ¼ä´ÁµÄ¾ßÌåÒâÒå¡£Óï·¨£º
Array getdate([int timestamp])
º¬Ò壺ti ......
½üÀ´ÓÉÓÚ¹¤×÷µÄÐèÒª£¬¿ªÊ¼Ñ§Ï°Ê¹ÓÃPHP¡£
´Ó×òÌìÏÂÎçµ½½ñÌìÉÏÎ磬ÖÕÓÚ°Ñ¿ª·¢»·¾³´î½¨Íê±Ï¡£×ܵÄÀ´Ëµ£º³õ²½µÄÈÏʶÊÇ£ºPHPÔÚÍøÕ¾¿ª·¢ÉÏ£¬¹¦ÄÜ»¹ÊǺÜÇ¿´óµÄ¡£½ñÌìÏÂÎç³õ²½µÄ°ÑÓ﷨ʲôµÄÊìϤһÏ¡£ÒòΪ×ö¿ª·¢Õâô¶àÄêÁË£¬ºÜ¶àÓïÑÔ£¬»¹ÊÇÓеãÏàͬµÄ£¬ËùÒÔ£¬Ñ§Ï°ÆðÀ´²»ÊǺܷѾ¢¡£ºóÌì»ØÀϼң¬Ï£ÍûÄêºóÄÜÔÚPHPÉÏÓÐËùÌá¸ß¡£
Ò»¡¢± ......
תÔØ×Ô£ºhttp://www.gracecode.com/archives/3013/
×÷ÕߣºÊÖÆø²»´í
ÕæµÄÊDz»Óò»ÖªµÀ£¬ÆäʵÎÒÃÇÊìϤµÄ PHP »¹ÓкܶàºÃ¶«Î÷ûÓз¢¾ò¡£¿´µ½ÕâƪÎÄÕÂ
£¬µ±Ê±¾ÍÀá±¼Á˺ü¸»Ø£¬ÖصãÍƼöÏ£¬Ë³±ãÎÒ×Ô¼ºÒ²×ö¸öÕûÀí¡£
sys_getloadavg()
Õâ¸öº¯Êý
·µ»Øµ±Ç°ÏµÍ³µÄ¸ºÔؾùÖµÐÅÏ¢
£¨µ±È» Windows ϲ»ÊÊÓã©£¬ÏêϸÎĵµ¿ÉÒÔ·ÔÄ PH ......
/***************************by
garcon1986********************************/
<?php
//if Óï¾ä
$a = $b = 3;
if($a = $b)
print "a is equal to b<br>";
//else Óï¾ä
if($a < $b){
print "a is smaller than b";
} else {
print "a is not smaller than b<br> ......