Jump to content

edecode

Members
  • Posts

    1
  • Joined

  • Last visited

Posts posted by edecode

  1. Hello guys,

     

    I am studying about function eval() and I can't know how and why this functions is necessary! I wrote this code:

    <?php
    		$string = "beautiful";
    		$time = "winter";
    
    		$str = 'This is a $string $time morning!';
    		echo $str. "<br>";
    
    		eval("\$str = \"$str\";");
    		echo $str;
    
    		$code1 = "echo 'Hello World!'; ";
    		$code2 = "?>";
    		 
    		$code_php = '<?php $code1 $code2';
    		echo $code_php;
    
    		eval("\$code_php = \"$code_php\";");
    		echo $code_php;
    		
    ?>

    On first echo the result should be this: "This is a beautiful winter morning!", that's right?

    On second echo the result should be a code in php "This is a $string $time morning!"

    On third echo the result should be this: "Hello World"

    Lastly, the fourth echo the result should be a code in php: "<?php $code1 $code2"

     

    Am I do this right?

    Thanks

     

     

×
×
  • Create New...