php »ù´¡±Ê¼Ç string
/***************************by
garcon1986********************************/
<?php
// example for strings, single quoted, double quoted
echo 'display a string!<br>';
echo ' this displays
a splitted
string<br>';
echo 'i\'ll be "back"<br>';
echo 'she said:"i\'ll be back!"<br>';
echo 'the path is c:\programmes\sjg\*.*!'.' '.'hello world<br>';
echo 'the path is c:\\prgralles\\sjg\*.*<p>';
$h = 'hellos';
$i = "hellos";
echo '$h<br>';
echo "$h"."<br>";
echo '$i<br>';
echo "$i<br>";
//heredoc example
$str = <<<EOD
Example of string
spanning multiple lines
using heredoc syntax.
EOD;
/* More complex example, with variables. */
class foo
{
var $foo;
var $bar;
function foo()
{
$this->foo = 'Foo';
$this->bar = array('Bar1', 'Bar2', 'Bar3');
}
}
$foo = new foo();
$name = 'MyName';
echo <<<EOT
My name is "$name". I am printing some $foo->foo.
Now, I am printing some {$foo->bar[1]}.
This should print a capital 'A': \x41
EOT;
echo '$str<br>';
echo "$str<p>";
// variable parsing
$beer = "xuehua";
echo "$beer's taste is good<br>";// works; "'" is an invalid character for variable names
echo "he drinks some $beers<br>";// won't work; 's' is a valid character for variable names but the variable is "$beer
echo "he drinks some ${beer}s<br>";//works
echo "he drinks some {$beer}s<br>";//works
error_reporting(E_ALL);
$fruits = array('strawberry' => 'red', 'banana' => 'yellow');
echo "A banana is $fruits[banana].<br>";
echo "A banana is {$fruits['banana']}.<br>";
echo "A banana is {$fruits[banana]}.<br>"; // Works but PHP looks for a constant named
Ïà¹ØÎĵµ£º
ÔÎÄÁ´½Ó£ºhttp://www.phpdo.net/index.php/2010/02/10/1-13/
PHPÖÐÒ»¸ö»ù±¾µÄ½Å±¾ÓÉÁ½²¿·Ö×é³É£ºÖ÷³ÌÐòºÍº¯Êý¡£
º¯Êý²»½ö¿ÉÒÔ¹¹³ÉÒ»¸öPHP½Å±¾µÄ»ù±¾¹¦ÄÜ£¬Ò²Ê¹µÃ³ÌÐò½á¹¹»¯£¬ÓÐÖúÓÚ³ÌÐò´úÂëµÄÖØÓá£
PHPº¯ÊýµÄµ÷ÓÃ
ͨ¹ý°´ÕÕº¯Êý¸ñʽд³öº¯ÊýÒÔ¼°ÏàÓ¦µÄ²ÎÊý¼´¿É£¬ÒÂÓï·¨ÈçÏ£º
String¡¡substr(string¡¡str,int¡¡start) ......
¿´
µ½ÕâÆªÎÄÕÂ
£¬µ±Ê±¾ÍÀá±¼Á˺ü¸»Ø£¬ÖصãÍÆ¼öÏ£¬Ë³±ãÎÒ×Ô¼ºÒ²×ö¸öÕûÀí¡£
sys_getloadavg()
Õâ¸öº¯Êý
·µ»Øµ±Ç°ÏµÍ³µÄ¸ºÔؾùÖµÐÅÏ¢
£¨µ±È» Windows
ϲ»ÊÊÓã©£¬ÏêϸÎĵµ¿ÉÒÔ·ÔÄ PHP µÄÏà¹ØÎĵµ¡£ÎĵµÖÐÓжÎʾÀý´úÂ룬»ù±¾ÉÏÒ²¾ÍÄÜ¿´³öËüµÄÓÃ;ÁË¡£
<?php
$load = sys_getloadavg();
if ($load[0] > 80) ......
½üÀ´ÓÉÓÚ¹¤×÷µÄÐèÒª£¬¿ªÊ¼Ñ§Ï°Ê¹ÓÃPHP¡£
´Ó×òÌìÏÂÎçµ½½ñÌìÉÏÎ磬ÖÕÓÚ°Ñ¿ª·¢»·¾³´î½¨Íê±Ï¡£×ܵÄÀ´Ëµ£º³õ²½µÄÈÏʶÊÇ£ºPHPÔÚÍøÕ¾¿ª·¢ÉÏ£¬¹¦ÄÜ»¹ÊǺÜÇ¿´óµÄ¡£½ñÌìÏÂÎç³õ²½µÄ°ÑÓ﷨ʲôµÄÊìϤһÏ¡£ÒòΪ×ö¿ª·¢Õâô¶àÄêÁË£¬ºÜ¶àÓïÑÔ£¬»¹ÊÇÓеãÏàͬµÄ£¬ËùÒÔ£¬Ñ§Ï°ÆðÀ´²»ÊǺܷѾ¢¡£ºóÌì»ØÀϼң¬Ï£ÍûÄêºóÄÜÔÚPHPÉÏÓÐËùÌá¸ß¡£
Ò»¡¢± ......
/***************************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 y ......
/***************************by
garcon1986********************************/
<?php
//¼òµ¥Ê¾Àý
class SimpleClass
{
public $var = 'a default value';
public function displayVar(){
echo $this->var;
}
}
// create an object´´½¨Ò»¸ö¶ÔÏó
$A = new SimpleClass;
//µ÷Ó÷½·¨
$A -> displayVa ......