سؤال

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