ѧϰPHP(1)
»ù±¾Óï·¨
ÎҵĵÚÒ»¸öPHP£ºHello World
<?php
echo"Hello World!";
?>
ÏÔʾ½á¹ûΪ Hello World!
±äÁ¿
PHPÖУ¬ËùÓеıäÁ¿¶¼ÒÔ±êʶ“$”¿ªÍ·:
<?php
$str1 = "Hello World!";
echo $str1;
?>
ÏÔʾ½á¹ûΪ Hello World!
PHPÖÐʹÓÓ.”·ûºÅÁ¬½Ó²»Í¬µÄ×Ö·û´®¡£¾ÙÀýÈçÏ£º
<?php
$Str1 = "Hello, ";
$Str2 = 5;
$Str3 = " OH.C!";
$Str2++;
echo "$Str1"."$Str2"."$Str3"."<br/>";
//Ò²¿ÉÒÔ
echo "$Str1 $Str2 $Str3 <br/>";
?>
ÏÔʾ½á¹ûΪ
Hello, 6 OH.C!
Hello, 6 OH.C!
Èç¹ûûÓÐÒýºÅ£¬Ð´³ÉÒÔÏÂÐÎʽ
<?php
$Str1 = "Hello, ";
$Str2 = 5;
$Str3 = " OH.C!";
$Str2++;
echo $Str1.$Str2.$Str3."<br/>"; //ÕýÈ·
echo $Str1 $Str2 $Str3 "<br/>"; //´íÎó
?>
PHP¶Ô¸÷ÖÖÔËËã·û¼°ÔËËã¹æÔò¶¼ÓÐÒ»Ì×ÍêÕûµÄ¹æ¶¨£¬Èç¹ûÓû§¾ßÓÐC»òC++ÓïÑԵıà³Ì±³¾°µÄ»°£¬¿ÉÒÔ·¢ÏÖÒ»Çж¼µÃÐÄÓ¦ÊÖ¡£
ÓëPerlÓïÑÔÒ»Ñù£¬ÔÚPHPÖУ¬Èç¹ûÔÚË«ÒýºÅ°üº¬µÄ×Ö·û´®Öк¬ÓбäÁ¿µÄ»°£¬¸Ã±äÁ¿½«ÓÃÏàÓ¦µÄ±äÁ¿ÖµÌæ»»£»Èç¹û×Ö·û´®±»µ¥ÒýºÅ°üº¬£¬Ôò²»×öÌæ»»¡£ÀýÈ磺
<?php
$MyName = "OH.C";
$Str1 = "Hello, $MyName";
$Str2 = 'Hello, $MyName';
echo "Str1: $Str1"."<br>";
echo "Str2: $Str2 <br>";
echo "--------------------<br>";
echo 'Str1: $Str1'.'<br>';
echo 'Str2: $Str2 <br>';
?>
ÏÔʾ½á¹ûΪ
Str1: Hello, OH.C
Str2: Hello, $MyName
--------------------
Str1: $Str1
Str2: $Str2
Êý×é
Óû§ÔÚʹÓÃPHP´´½¨Êý×éʱ£¬¿ÉÒÔ°ÑÊý×éË÷Òý£¨°üÀ¨³£¹æË÷Òý»ò¹ØÁªË÷Òý£©¼ÓÈë·½À¨ºÅÖС£ÀýÈ磺
<?php
$ArrStr1[0] = 'Hello!';
$ArrStr1[1] = 'How are you?';
echo $ArrStr1[0]."<br/>";
echo $ArrStr1[1]."<br/>";
echo"----------------------<br/>";
$ArrStr2['animal'] = 'tiger';
$ArrStr2['company'] = 'IBM';
echo $ArrStr2['animal']."<br/>";
echo $ArrStr2['company']."<br/>";
?>
ÏÔʾ½á¹ûΪ
Hello!
How are you?
----------------------
tiger
IBM
Èç¹ûÓû§ÔÚÏòÊý×鸳ֵʱ²»Ö¸Ã÷Êý×éϱ꣬PHP½«×Ô¶¯°Ñ¸Ã¶ÔÏó¼ÓÈëµ½Êý×éĩβ¡£ÀýÈç¶ÔÓÚÉÏÊö$$ArrStr1Êý×é¿ÉÒÔÓÃÒÔÏ·½Ê½¸³Öµ¶ø±£³Ö½á¹û²»±ä£¬
<?php
$ArrStr1[0] = 'Hello!';
$ArrStr1[1] = 'How are yo
Ïà¹ØÎĵµ£º
<?php
$HotSong="°®ÇéתÒÆ|¾Õ»¨Ì¨|Àë¸è|ÔÂÁÁÖ®ÉÏ|ÒþÐεijá°ò|Öйú»°|Çó·ð|ÇïÌì²»»ØÀ´|·¢ÏÖ°®|ÄѵÀ°®Ò»¸öÈËÓдíÂð|ǧÀïÖ®Íâ|Á¬¿Þ¶¼ÊÇÎҵĴí";
function HotSo($HotSong){
$HotSo='';
echo($HotSong);
$b=explode('|',$HotSong);
foreach ($b as $v) {
$HotSo.="<a href="song.php?song=".urlencode($v)."" mce_ ......
php±íµ¥ÔÚÌá½»Ö®ºóÔÙºóÍË,±íµ¥µÄÄÚÈÝĬÈÏÊDZ»Çå¿ÕµÄ(ʹÓÃsession_startµÄʱºò),
½â¾ö·½·¨ÊÇÔÚsession_start()Ö®ºó,×Ö·ûÊä³ö֮ǰдÉÏ
header(“Cache-control: private”);
ÍøÒ³µÄ»º´æÊÇÓÉHTTPÏûϢͷÖеēCache-control”À´¿ØÖƵģ¬³£¼ûµÄÈ¡ÖµÓÐprivate¡¢no- cache¡¢max-age¡ ......
¡¡PHPÖеÄ×Ö·û´®²Ù×÷¹¦ÄÜÊDZȽ϶àµÄ,ÖØÒªµÄÓÐÒÔÏÂÕâЩ:
¡¡¡¡(1)echo,print,printf,sprintf
¡¡¡¡Ç°Á½¸öº¯ÊýÊÇÊä³ö×Ö·û´®.×Ö·û´®ÖÐÈç¹ûÓбäÁ¿ÃûÔò±»Ìæ»»³ÉÆäÖµ. ºóÁ½¸öº¯ÊýÀàËÆÓÚCµÄͬÃûº¯Êý.
¡¡¡¡(2)strchr,strlen,strtok,strrchr,strrev,strstr,strtolower, strtoupper,substr,ucfirst
¡¡¡¡ÕâЩÊdz£ÓõÄ×Ö·û´®²Ù×÷º¯Êý, ......
<?php
/**
* °ÑÒ»¸öºº×ÖתΪunicodeµÄͨÓú¯Êý£¬²»ÒÀÀµÈκο⣬ºÍ±ðµÄ×Ô¶¨Ò庯Êý£¬µ«ÓÐÌõ¼þ
* Ìõ¼þ£º±¾ÎļþÒÔ¼°º¯ÊýµÄÊäÈë²ÎÊýÓ¦¸ÃÓÃutf-8±àÂ룬²»È»Òª¼Óº¯Êýת»»
* ÆäʵÒà¿ÉÇáÒ×±àд·´Ïòת»»µÄº¯Êý£¬ÉõÖÁ²»¾ÖÏÞÓÚºº×Ö£¬Ææ¹ÖΪʲôPHPûÓÐÏֳɺ¯Êý
* @author xieye
*
* @param {string} $word ±ØÐëÊÇÒ»¸öºº ......
<?php
/**
+++++++++++++++++++++=+++++ÉÏ´«Í¼Æ¬++++++++++++++++++++++++++++++++++++++++
—————————————————————————————&mdas ......