Heim >Backend-Entwicklung >PHP-Tutorial >trim去掉特殊符号$的问题

trim去掉特殊符号$的问题

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-20 12:31:241224Durchsuche

 $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,"$");

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Vorheriger Artikel:mac下PHP安装扩展phpreidsNächster Artikel:mysql排序问题~