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.

Was it helpful?

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");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top