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".'<br>';
}else {
echo "action is true".'<br>';
}
//some var_dump exercise ---------- var_dump print the relational information of variables
var_dump((bool)""); //bool(false)
var_dump((bool) 1); //bool(true)
var_dump((bool) 0); //bool(false)
var_dump((bool) -1); //bool(true)
var_dump((bool) -2); //bool(true)
var_dump((bool) "foo"); //bool(true)
var_dump((bool) 2.3e5); //bool(true)
var_dump((bool) array()); //bool(false)
var_dump((bool) array(12)); //bool(true)
var_dump((bool) "false"); //bool(true)
//var_dump
$a = 3;
$b = "s1";
//$c = var_dump($a); // int(3)
$d = var_dump($a, $b);
var_dump((bool)00190); // bool(true)
var_dump(00190); // int(1)
$large_number = 2147483647;
var_dump($large_number);
// output: int(2147483647)
$large_number = 2147483648;
var_dump($large_number);
// output: float(2147483648)
// it's true also for hexadecimal specified integers between 2^31 and 2^32-1:
var_dump( 0xffffffff );
// output: float(4294967295)
// this doesn't go for hexadecimal specified integers above 2^32-1:
var_dump( 0x100000000 );
// output: int(2147483647)
$million = 1000000;
$large_number = 50000 * $million;
var_dump($large_number);
// output: float(50000000000)
var_dump(25/7); //output float(3.5714285714286)
var_dump((int)(25/7)); // int(3)
var_dump((boolean)(25/7));// boolean(true)
var_dump(round (25/7)); // float(4)
//special conditions Warning:Never cast an unknown fraction to integer, as this can sometimes lead to unexpected results.
echo (int)((0.1+0.7)*10); // echoes 7!
echo (int)((0.26-0.1)*100); //echoes 16
?>
相关文档:
原文链接:http://www.phpdo.net/index.php/2010/02/10/1-13/
PHP中一个基本的脚本由两部分组成:主程序和函数。
函数不仅可以构成一个PHP脚本的基本功能,也使得程序结构化,有助于程序代码的重用。
PHP函数的调用
通过按照函数格式写出函数以及相应的参数即可,衣语法如下:
String substr(string str,int start) ......
apache的源码安装
将压缩包解压之后进入相应的目录
./configure \ #--------------------预编译命令
"--prefix=/usr/local/apache" \ #--------------------安装路径为“/usr/local/apache”
"--with-included-apr" \
"--enable-so" \ #--------------------开启相应的扩展模块 ......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>PHP分页</tit ......
/***************************by
garcon1986********************************/
<?php
//if 语句
$a = $b = 3;
if($a = $b)
print "a is equal to b<br>";
//else 语句
if($a < $b){
print "a is smaller than b";
} else {
print "a is not smaller than b<br> ......
/***************************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);
// =& ......