Insert PHP Code In PHP Variable -


i have simple question,

how insert php code in php variable?

example :

echo $value = " bla bla <?php $q = "select * bla bla"; ?> "; 

you can using eval()

$test = <<<end <p> <?php  echo time();  ?> </p> end;   ob_start(); eval("?>$test"); $result = ob_get_clean(); 

or other example w3s:

<?php $string = "beautiful"; $time = "winter";  $str = 'this $string $time morning!'; echo $str. "<br>";  eval("\$str = \"$str\";"); echo $str; ?> 

will print

this $string $time morning!

this beautiful winter morning!

source

but carefull when use it, php page:

caution eval() language construct dangerous because allows execution of arbitrary php code. use discouraged. if have verified there no other option use construct, pay special attention not pass user provided data without validating beforehand.


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -