adding php variable into Xpath

前端 未结 1 680
孤城傲影
孤城傲影 2021-01-22 20:31

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 somet

相关标签:
1条回答
  • 2021-01-22 21:32

    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 讨论(0)
提交回复
热议问题