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
Ïà¹ØÎĵµ£º
5.¹ØÓÚ±íµ¥Ë¢ÐÂ
ÎÊ£ºÎªÊ²Ã´ÎÒÔÚµã»÷ä¯ÀÀÆ÷µÄºóÍË°´Å¥ºó£¬ËùÓÐ×ֶεÄÐÅÏ¢¶¼±»Çå¿ÕÁË£¿
´ð£ºÕâÊÇÓÉÓÚÄãÔÚÄãµÄ±íµ¥Ìá½»Ò³ÃæÖÐʹÓÃÁË session_start º¯Êý¡£¸Ãº¯Êý»áÇ¿ÖƵ±Ç°Ò³Ãæ²»±»»º´æ¡£½â¾ö°ì·¨Îª£¬ÔÚÄãµÄ Session_start º¯Êýºó¼ÓÈë header("Cache-control: private"); ×¢ÒâÔÚ±¾ÐÐ֮ǰÄãµÄPHP³ÌÐò²»ÄÜÓÐÈκÎÊä³ö¡£
²¹³ä£º ......
½üÀ´ÓÉÓÚ¹¤×÷µÄÐèÒª£¬¿ªÊ¼Ñ§Ï°Ê¹ÓÃPHP¡£
´Ó×òÌìÏÂÎçµ½½ñÌìÉÏÎ磬ÖÕÓÚ°Ñ¿ª·¢»·¾³´î½¨Íê±Ï¡£×ܵÄÀ´Ëµ£º³õ²½µÄÈÏʶÊÇ£ºPHPÔÚÍøÕ¾¿ª·¢ÉÏ£¬¹¦ÄÜ»¹ÊǺÜÇ¿´óµÄ¡£½ñÌìÏÂÎç³õ²½µÄ°ÑÓ﷨ʲôµÄÊìϤһÏ¡£ÒòΪ×ö¿ª·¢Õâô¶àÄêÁË£¬ºÜ¶àÓïÑÔ£¬»¹ÊÇÓеãÏàͬµÄ£¬ËùÒÔ£¬Ñ§Ï°ÆðÀ´²»ÊǺܷѾ¢¡£ºóÌì»ØÀϼң¬Ï£ÍûÄêºóÄÜÔÚPHPÉÏÓÐËùÌá¸ß¡£
Ò»¡¢± ......
xml񈬀<?php ?>
½Å±¾·ç¸ñ <script language="php"></script>
¶Ì±ê¼Ç<? ?>
asp񈬀<% %>
Èç¹ûÏëÖ§³Ö¶Ì±ê¼ÇºÍasp±ê¼Ç£¬ÐèÒªÔÚphp.iniÖÐÅäÖÃ
short_open_tag
asp_tags
ÉèΪon ......
/***************************by
garcon1986********************************/
<?php
// simple assgin the values
$arr1 = array(12 => 10, 'sjg' => 'yaya');
echo $arr1[12].'<br>'; // 10
echo $arr1['sjg']."<br>"; //yaya
echo "wo ai ni !<p> ......
/***************************by
garcon1986********************************/
<?php
// boolean integer float example
$action = false;
if($action == "show version"){
echo "the version is 123".'<br>';
}else if($action == false){
echo "action is false".'< ......