$a=false; $a=""; $a=0;
$b=false;
echo $a==$b?"true":"false";
单引号和双引号的区别:
单引号内部的变量不会执行
双引号会执行
如
$name = 'hello';
echo "the $name";
会输出 the hello
而如果是单引号
$name = 'hello';
echo 'the $name';
会输出 the $name
public function demo() {
// $a=array("Dog","Cat","Horse");
// echo array_pop($a);exit;
// print_r($a);
$baseurl = 'http://www.abc.com/a/index.html';
$srcurl = '../abc/a.js';
// http://www.abc.com/abc/a.js
$srcinfo = parse_url ( $srcurl );
// Array
// (
// [path] => ../abc/a.js
// )
if (isset ( $srcinfo ['scheme'] )) {
return $srcurl;
}
$baseinfo = parse_url ( $baseurl );
// Array
// (
// [scheme] => http
// [host] => www.abc.com
// [path] => /a/index.html
// )
$url = $baseinfo ['scheme'] . '://' . $baseinfo ['host'];
if (substr ( $srcinfo ['path'], 0, 1 ) == '/') {
$path = $srcinfo ['path'];
} else {
$path = dirname ( $baseinfo ['path'] ) . '/' . $srcinfo ['path'];
// /a/../abc/a.js
}
$rst = array ();
$path_array = explode ( '/', $path );
// Array
// (
// [0] =>
// [1] => a
// [2] => ..
// [3] => abc
// [4] => a.js
// )
if (! $path_array [0]) {
$rst [] = '';
}
foreach ( $path_array as $key => $dir ) {
if ($dir == '..') {
if (end ( $rst ) == '..') {
$rst [] = '..';
} elseif (! array_pop ( $rst )) {
$rst [] = '..';
}
} elseif ($dir && $dir != '.') {
$rst [] = $dir;
}
}
if (! end ( $path_array )) {
$rst [] = '';
}
$url .= implode ( '/', $rst );//print_r($url);
// echo str_replace ( '\\', '/', $url );
}