随笔分类 - PHP
PHP中const的使用
摘要:1 <html> 2 <body> 3 <!-- 类内声明及使用 --> 4 <?php 5 class TestConst { 6 const COUNTRY = 'China'; //const不能加public,static,也不需要$ 7 static $static = 'Static'; 8 9 public function getCountry() {10...
阅读全文
PHP计算两个路径的相对路径
摘要:1 <html> 2 <body> 3 <?php 4 function relativePath($aPath, $bPath) { 5 $aArr = explode('/', $aPath); //explode函数用于切分字符串,返回切分后的数组,此处用'/'切分字符串 6 $bArr = explode('/', $bPath); 7 $aDiffToB = array_diff_assoc($aArr, $bArr); //a...
阅读全文