简体   繁体   English

在锚标记中将“双引号替换为”单引号

[英]Replace " double quote for ' single quote when it's in an anchor tag

Hi im creating a xml file but i need to change this. 嗨,即时通讯创建一个XML文件,但我需要更改此。

<a href="http://www.whatever.com/" target="_blank">lorem</a>

for this 为了这

<a href='http://www.whatever.com/' target='_blank'>lorem</a>

I do it like this: 我这样做是这样的:

$valFieldBody = "<a href='http://www.whatever.com/' target='_blank'>lorem</a>";
$valFieldBody = str_replace('"', "'", $valFieldBody);

but the output is 但输出是

<a href="http://www.whatever.com/" target="_blank">lorem</a>

but if i check de source code it shows like 但是,如果我检查了源代码,它显示为

<a href='http://www.whatever.com/' target='_blank'>lorem</a> 

could you please help me 请你帮助我好吗

but the output is … but if i check de source code it shows like 但是输出是…但是如果我检查源代码,它显示为

This doesn't make a lot of sense. 这没有多大意义。 I think you mean: 我想你的意思是:

  • The source code shows ' around the attribute values 源代码在属性值周围显示'
  • The DOM Inspector in your browser shows " around the attribute values 浏览器中的DOM检查器在属性值周围显示"

This is normal and there is nothing you can do about it. 这是正常现象,您无能为力。

The browser will parse the HTML source code and use it to create a DOM. 浏览器将解析HTML源代码并使用它来创建DOM。 It will apply rules for optional start and end tags. 它将对可选的开始和结束标记应用规则。 It will apply error recovery. 它将应用错误恢复。 The DOM might be manipulated by JavaScript. DOM可能由JavaScript操纵。 The DOM Inspector will then show a serialised version of that DOM. 然后,DOM检查器将显示该DOM的序列化版本。

It doesn't matter what type of quotes were used around the attribute value in the source code. 在源代码中的属性值周围使用哪种类型的引号都没有关系。 The browser will always use " when it generates the HTML visualisation of the DOM for the DOM inspector. 当浏览器为DOM检查器生成DOM的HTML可视化图像时,它将始终使用"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM