将 php 变量添加到 Xpath [英] adding php variable into Xpath
本文介绍了将 php 变量添加到 Xpath的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只需要在xpath中添加一个变量,我的代码如下
i just need to add in a variable into the xpath my code is as followed
$target = $xml->xpath('//gig[@id=$1]');
但我也需要它,但就像
$target = $xml->xpath("//gig[@id=$" $change . "]");
这可能吗?
如果可以,有人可以帮忙吗?
If so could some one help ?
推荐答案
使用:
$target = $xml->xpath("//gig[@id=$". $change . "]");
或者,如果您不需要 $ 符号
or, if you do not need the $ sign
$target = $xml->xpath("//gig[@id=". $change . "]");
如果您需要在 php 中转义像 " 这样的字符,请使用
If you need to escape a character like " in php use
\"
这篇关于将 php 变量添加到 Xpath的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文