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

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数据类型的转换

原文链接:http://www.phpdo.net/index.php/2010/02/09/1-12/
PHP的数据类型的转换有两种方法可以办到:直接输入目标的数据类型和通过settype函数实现。
PHP数据转换成整数
Float型数据转换成int型
Float型转换成int型,小数点后的数将被舍弃。如果float数超贵超过了整型的取值范围,那么结果可能是0或者是整形的最小负 ......

php tips

5.关于表单刷新
问:为什么我在点击浏览器的后退按钮后,所有字段的信息都被清空了?
答:这是由于你在你的表单提交页面中使用了 session_start 函数。该函数会强制当前页面不被缓存。解决办法为,在你的 Session_start 函数后加入 header("Cache-control: private"); 注意在本行之前你的PHP程序不能有任何输出。
补充: ......

Nginx+PHP+MySQL双机互备、全自动切换方案[转]

在生产应用中,某台“Nginx+PHP+MySQL”接口数据服务器,扮演的角色十分重要,如果服务器硬件或Nginx、MySQL发生故障,而短时间内无法恢复,后果将非常严重。为了避免单点故障,我设计了此套方案,编写了failover.sh脚本,实现了双机互备、全自动切换,故障转移时间只需几十秒。
  一、双机互备、全自动切换方 ......

php向MySQL插入数据不全 解决方法

今天为了一些已有数据导入MYSQL的数据库,我写了一个很简单的PHP程序。
程序思路很简单,就是读一条数据,然后往MYSQL里插入一条。
结果总是发现 每次导入只能导入2000条,就自动停止了,而且没有任何提示。
在网上搜解决方案各种搜不到。
刚开始怀疑是内存缓冲给少了,调了一下,还是不行。。
最后发现一个规律,就是 ......

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