문제

I received 'lang1', 'subject' variables. And I want to write 2 varibles in file name as like below code.

  <?php
   $subject=$_POST['subject'];
   $lang1=$_POST['lang1'];

    $xmlDoc=new DOMDocument();
    $xmlDoc->load("ds_'.$lang1.'_'.$subject.'.xml");

Last programming phrase is something wrong. Please correct that.

Thank you for your attention.

도움이 되었습니까?

해결책

You get an error because you are mixing up your quotes. If you start a string with double quotes you need to close the string with double quotes as well.

$xmlDoc->load("ds_".$lang1."_".$subject.".xml");

or

$xmlDoc->load('ds_'.$lang1.'_'.$subject.'.xml');

or

$xmlDoc->load("ds_{$lang1}_{$subject}.xml");
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top