易截截图软件、单文件、免安装、纯绿色、仅160KB

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


相关文档:

PHP函数的定义与使用

原文链接:http://www.phpdo.net/index.php/2010/02/10/1-13/
PHP中一个基本的脚本由两部分组成:主程序和函数。
函数不仅可以构成一个PHP脚本的基本功能,也使得程序结构化,有助于程序代码的重用。
PHP函数的调用
通过按照函数格式写出函数以及相应的参数即可,衣语法如下:
String substr(string str,int start) ......

php 基础笔记 operators

/***************************by
garcon1986********************************/
<?php
//php avancé 5 example
$a = 'hello';
$a .= 'world';
$table = 'users';
$id = 5;
$sql = 'SELECT * from'.$table. "WHERE ID = '$id'";
//date() G显示24小时的格式,i显示分钟
echo 'il est'.date( ......

php基础笔记 Arrow difference

/***************************by
garcon1986********************************/
<?php
// -> 是指对象的方法或者属性
class Cart{
public function add_item($a,$b){
echo $a+$b.'<br>';
}
}
//$cart = new Cart; 两句意义相同
$cart = new Cart();
$cart->add_item("10", 1);
// =& ......

php 基础笔记 boolean integer float

/***************************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".'< ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号