字符串最后一个字符是什么? 一个字符串http://www.csdn.net/如果最后一个字符是/就变成http://www.csdn.net/index.php否则不变 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 $str = "http://www.csdn.net/";if(substr($str,-1) == "/") $str .= "index.php"; $str = "http://www.csdn.net/";if(substr($str,-1) == "/") $str .= "index.php";或者:应该根据你的需要来定$str = "http://www.csdn.net/";if(substr($str,-1) == "/") $str .= "index.html"; <?php$str = "http://www.csdn.net/";if(ereg("/$",$str)){ echo $str .= "index.php";}echo"<br />";$str = "http://www.csdn.net/";if(preg_match("'/$'",$str)){ echo $str .= "index.php";} 用正则表达式,可写作$str = "http://www.csdn.net/";echo ereg_replace("/$","/index.php",$str); <?phpecho substr("http://www.csdn.net/",-1);?> array_flip的郁闷问题 php 批量录入学生成绩表中 PHP跳转到模式窗体(传值) PHP分页遇到的问题 在php中用adodb连接sybase client时出错 PHP语法 从oracle中读数据插入到MYSQL里,用的是phplib,出现了类名称相同如何解决? 请帮忙!!急!!! 有个点子,谁会做地图上某些城市的客户的统计,完全用图片显示? 急救!!(在线...........等!!!) 请教一个关于smarty模板得问题,请多多帮忙! 高分请教有关ORACLE分页的问题!
if(substr($str,-1) == "/")
$str .= "index.php";
if(substr($str,-1) == "/")
$str .= "index.php";或者:应该根据你的需要来定
$str = "http://www.csdn.net/";
if(substr($str,-1) == "/")
$str .= "index.html";
$str = "http://www.csdn.net/";
if(ereg("/$",$str)){
echo $str .= "index.php";
}
echo"<br />";$str = "http://www.csdn.net/";
if(preg_match("'/$'",$str)){
echo $str .= "index.php";
}
$str = "http://www.csdn.net/";
echo ereg_replace("/$","/index.php",$str);
echo substr("http://www.csdn.net/",-1);
?>