开发者

adding php variable into Xpath

开发者 https://www.devze.com 2022-12-17 11:03 出处:网络
i just need to add in a variable into the xpath my code is as followed $target = $xml->xpath(\'//gig[@id=$1]\');

i just need to add in a variable into the xpath my code is as followed

$target = $xml->xpath('//gig[@id=$1]');

but I need it too but something like

$target = $xml->xpath("//gig[@id=$" $change . "]"开发者_如何学Go);

Is this possible ?

If so could some one help ?


Use:

$target = $xml->xpath("//gig[@id=$". $change . "]");

or, if you do not need the $ sign

$target = $xml->xpath("//gig[@id=". $change . "]");

If you need to escape a character like " in php use

\"
0

精彩评论

暂无评论...
验证码 换一张
取 消