Search code examples
phpvariablesquotations

php calling variable within complex quotations


I'm trying to call a variable with a command that I need to send to windows CLI with no luck, if you could please help me out

$imagename = 123;

$test = ('C:\Windows\System32\cmd.exe /c "rundll32.exe C:\Windows\System32\shimgvw.dll,ImageView_PrintTo /pt "c:\pathtodirectory\$imagename" "photoprint""');
echo $test

$imagename currently has a value of 123 but I am unable to call it within several quotations please help.

Thanks.


Solution

  • What about this one?

    $imagename = 123;
    $test = 'C:\Windows\System32\cmd.exe /c "rundll32.exe C:\Windows\System32\shimgvw.dll,ImageView_PrintTo /pt "c:\pathtodirectory\\' . $imagename . '" "photoprint"';
    echo $test;