Home >Backend Development >PHP Tutorial >trim去掉特殊符号$的问题

trim去掉特殊符号$的问题

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-20 12:31:241242browse

 $source ="$http://www.baidu.com/call.scv$";echo trim($source,"$");


目的是去除$source前后的 $ 号
但是输出为,多去除了http

://www.baidu.com/call.scv

求指点,谢谢!


回复讨论(解决方案)

$source ='$http://www.baidu.com/call.scv$';  这里应该是单引号
echo trim($source,'$');

$source ='$http://www.baidu.com/call.scv$';

改为单引号,双引号php会解析$http

error_reporting(E_ALL ^ E_NOTICE);$source ="$http://www.baidu.com/call.scv$";echo $source;
因为并不存在变量 $http,所以一开始 http 就不存在了
这样写才对
$source ='$http://www.baidu.com/call.scv$';echo trim($source,"$");

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:mac下PHP安装扩展phpreidsNext article:mysql排序问题~