switch($id){
case 1:
return 'asp/';
break;
case 2:
return 'phper/';
break;
case 3:
return 'jsp/';
break;
default:
return 'rubbish/';
}
if else实现
if( $systype == 1 || $systype == 2 || $systype == 3 || $systype == 4 ){
return $sever;
}elseif ( $systype == 5 || $systype == 6 || $systype == 10
|| $systype == 11 || $systype == 12 || $systype == 9 || $systype ==7 ){
return $js;
}elseif ( $systype == 9 || $systype == 8 ){
return $sql;
}else{
return $system.$sever;
}
从上面的实例我们可以看出switch只能做一个选择,而if else 可以多个。
本站原创转载注明: www.111cn.net/php/phper.html
__FILE__在php是表示当前文件绝对路径哦,下面我们来看看简单的FILE的实例吧。《?php
echo __FILE__;
?>
E:phpinfo.php
那么我们会看到很多cms中会这样写
dirname(__FILE__);
这样会是什么结果呢,我们来试一下吧。
《?php
echo dirname(__FILE__);
?>
输出为 E:php
哈哈,明白了没其它的我就不说多了。
本站原创转载注明:www.111cn.net/phper/php.html
这是一款我自己没事时写的一款简单的把php文件生成html静态页面的程序代码哦,就是用str_replace来替换函数返回的数据就OK了。$fileName = md5_filename($rs[0],$rs['z_a'],$rs['filesendid']);
$path = get_path($rs['sysa']).$rs['z_a'].'/';
$parent = $_SERVER["DOCUMENT_ROOT"];//substr(getcwd(),0,strrpos(getcwd(),'\'));
$filePath = $parent.'\'.$path;
$tempLate = str_replace('{path}',path($rs['z_a'],$rs['sysa']),$fileContent);
$tempLate = str_replace('{htmlAbout}',htmlAbout($rs['z_a'],10,8,0,''),$tempLate);
$tempLate = str_replace('{htmlTemplate}',htmlTemplate(0),$tempLate);
$tempLate = str_replace('{htmlMenu}',htmlMenu($rs['sysa']),$tempLate);
$tempLate = str_replace('{htmlHelp}',htmlHelp($rs['sysa']),$tempLate);
$tempLate = str_replace('{htmlNews}',htmlAbout($rs['z_a'],0,8,0,''),$tempLate);
$tempLate = str_replace('{htmlHot}',htmlAbout($rs['z_a'],0,8,1,''),$tempLate);
$tempLate = str_replace('{htmlSoure}',htmlTemplate(1),$tempLate);
$tempLate = str_replace('php简单生成html静态页面代码',$rs['title'],$tempLate);
$tempLate = str_replace('{htmlContent}',$rs['content'],$tempLate);
$tempLate = str_replace('{description}',$rs['description'],$tempLate);
$tempLate = str_replace('{keywords}',$rs['keywords'],$tempLate);
makeHtml($tempLate,$filePath,$fileName);
function makeHtml($msgContent,$filePath,$fileName){//生成html文件
if(!is_dir($filePath)){@mkdir($filePath);}
//die($filePath);
$handle = fopen(str_replace('\','../',$filePath.$fileName),'w+') or die("can't create file!$fileName");
fwrite($handle,$msgContent);
fclose($handle);
}
本站原创转截注明:www.111cn.net/phper/php.html
下面这个函数是一个读取指定文件的内容然后再用php explode 与 implode来进行分析,然后我们再讲一下explode与implode的区别与使用方法 function htmlTemplate($tag){
$url ="file.txt";//file文件里面保存的是我要所数据并且是以<!-- 内容 -->为界线的。
$content = file_get_contents($url); 读取文件
if( !empty( $content ) ){
$array = explode('<!-- 内容 -->',$content); //进行数据处理,然后保存到数组array里面
}else{
echo 'error';
}
if( $tag ){
return $array[1];//数据1里面是保存了一段数据
}
$temp = $array[16];
$tempArray = explode('</span>',$temp); //16里面有数据</span>所以我们再进行inplode对数据进行合并成字符串就OK了。
for($i = 0 ;$i<=3;$i++) {
$tArray[] =$tempArray[$i];
}
return implode("</span>",$tArray ).'</span>';
}
本站原创转载注明:www.111cn.net/phper/php.html
提供一款超简单的php Oracle 数据库 导出代码哦。提供一款超简单的php Oracle 数据库 导出代码哦。
<?php
$conn=OCILogon("用户名","密码","(DESCRIPTION=(ADDRESS=(PROTOCOL =TCP)(HOST=IP)(PORT = 1521))(CONNECT_DATA =(SID=lcx)))");
//$sql="select * from all_tab_columns where table_name='MEMBER'";//Table Structure
$sql="select USER_ID,PASSWORD from MEMBER where IDX < 100";//sql语句
$stmt = OCIParse($conn, $sql);
OCIExecute($stmt);
$rows = OCIFetchstatement($stmt,$results);
$keys = array_keys($results);
$table = "<table>n <TR>n";
foreach($keys as $key)
{
$table .= " <TH>$key</TH>n";
}
$table .= " </TR>n";
for($i=0;$i<$rows;$i++)
{
$table .= " <TR>";
foreach($results as $spalte)
{
$data = $spalte[$i];
$table .= " <TD>$data</TD>";
}
$table .=" </TR>";
}
echo $table;
$sStr="/home/lcx.htm";
fputs(fopen($sStr,'a+'),$table);
?>