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

trim去掉特殊符号$的问题

WBOY
Release: 2016-06-20 12:31:24
Original
1197 people have browsed it

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


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

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

求指点,谢谢!


回复讨论(解决方案)

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

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

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

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

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template