Question

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.

Était-ce utile?

La solution

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");
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top