[英]Php Str_replace for \' doesnt work
i have a title field for mysql field as this 我有一个mysql字段的标题字段
Newyork\' s best place
it seems 它似乎
Newyork\ s best place
i want to change it as 我想将其更改为
Mewyork's best place
i make this but it doesn't work 我做这个但是没有用
str_replace("\'", "'", $title);
Any suggestions? 有什么建议么?
Look this site title: http://www.kusadasisehirrehberi.com/ 查看此网站标题: http : //www.kusadasisehirrehberi.com/
Orijinal codes 原始码
functions.php 的functions.php
default:
$baslik=mysql_fetch_row(mysql_query("SELECT title from ayar where id=1 limit 0,1"));
$title=title_temizle($baslik['0']);
$title=str_replace("\'", "'", $title);
}
return $title;
}
header.php header.php文件
<title><?php echo $title ?> </title>
You need to use html_entity_decode... 您需要使用html_entity_decode ...
So: 所以:
<?php
echo html_entity_decode($field);
?>
In this example I assume that the string 在此示例中,我假设字符串
Newyork\\' s best place
纽约最好的地方
Is in $field. 在$ field中。
Also see: http://www.web2generators.com/html/entities 另请参阅: http : //www.web2generators.com/html/entities
======== ========
Updated: 更新:
Try the following, this should work for you. 请尝试以下操作,这将为您工作。
<title><?php echo html_entity_decode($title) ?> </title>
您还需要转义反斜杠-\\,因为在您的情况下,您还要转义&符号-&
str_replace("\\'", "'", $title);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.