php实现注释的删除【支持//,/*,/**】
<?php
$fileName="function.js";
$file=fopen($fileName,"r");
$writeStr="";
$flag=false;//判断是否有/***/标准
while($strLine=fgets($file))
{
if(stripos($strLine,"/*")===false || stripos($strLine,"/**")===false)
{
$flag=false;
}
else
{
$flag=true;
}
$writeStr.=$flag."\n";
if($flag===true)
{
if(stripos($strLine,"*/"))
{
$flag=false;
}
continue;
}
$writeStr.=filterStr($strLine)."\n";
}
fclose($file);
$file=fopen($fileName,"w");
fwrite($file,$writeStr);
fclose($file);
function filterStr($str)
{
$position=strpos($str,"//");
if($position===false)
{
return $str;
}
else
{
return substr($str,0,$position);
}
}
?>
相关文档:
用户定义的类,也是学好 PHP 所必备的条件之一。
而 PHP 的类,和其它的面向对象语言比较起来,还算蛮单纯的。
PHP 只有类别 (class)、方法 (method)、属性、以及单一继承 (extensions) 等。
对不习惯使用 C++、Java、Delphi 等面向对象语言来开发程序的用户,不妨先阅读一下有关面向对象概念的书,相信可以带来许多的收 ......
<?php
$host = "www.abc.com"; //你要访问的域名
$target = "/test.asp"; //你要访问的页面地址
$referer = "http://www.abcdefg.com/abc.html"; //伪造来路页面
$fp = fsockopen($host, 80, $errno, $errstr, 30);
if (!$fp){
echo "$errstr($errno)<br />\n";
} ......
php中set_include_path函数用法:
php中的set_include_path函数可用于设置应用程序目录,开发项目时合理应用这些函数,不但可以让我们在include时不用一层一层的计算目录,还可以提高我们开发的效率,减少文件包含错误率.
例如:
简历2个php文件,一个目录
位置结构如下
/index.php
/include/config.php
index.php ......
在学习php时,看到的,做个笔记
字符串头部:^
<?php echo ereg(“^hello”,”hello world!”); ?>
字符串尾部:$
<?php echo ereg(“bye$”,”goodbye”); ?>
任意的单个字符:.
<?php echo ereg(“.”,”goodbye”); ......