Jump to content

Recommended Posts

ok here is what i am trying to do and i hope you all can help me...

 

I have Mandrake Linux installed on one of my home pc's with lamp system on it. I have a portal script i created on my windows lamp pc that should basic work the same and it did but one thing...

 

here is the code that is giving me an issue:

 

    ob_start();

    $imp_file=implode("", file($filename)) ;

    $imp_file = addslashes($imp_file);

    eval($imp_file);

    $file_content = ob_get_contents();

    ob_end_flush();

 

what i am trying to send to this code is and html file with lets say <table width = $width>. What I want the eval to do is to take $width and make lets say 55%. I have everything correct i think and I have tried many other examples on the net for evaluating a string but all i get is an error:

 

    Parse error: syntax error, unexpected T_STRING in /var/www/html/Public_Html/PhpCurciut/themes/Voyix/theme.php(147) : eval()'d code on line 1

 

 

now just to let you know the theme looks simular to php nuke (i have also tried to use the way they eval there themes), but it still gave the same error

 

ex:

 

    $tmpl_file = "themes/$theme/content_page.html";

        $thefile = implode("", file($tmpl_file));

        $thefile = addslashes($thefile);

        $thefile = "\$r_file=\"".$thefile."\";";

        eval($thefile);

        print $r_file;

 

 

please help Im so lost lol

Link to comment
https://forums.phpfreaks.com/topic/131843-eval-and-ob_start-stuff/
Share on other sites

Try this so you can see what I mean:

 

bad.php

<b>$width</b>

 

good.php

<b><?php echo $width ?></b>

 

include.php

<?php
$width = 55;
echo "Width set up, test: $width<br />";
echo "Starting includes...<br />";
echo "bad.php:<br />";
include ('bad.php');
echo "<br />good.php:<br />";
include('good.php');
?>

 

Put all 3 of those files in the same folder and go to include.php.

maybe I should have said this before,  i am trying to purse an html file. in this file is only html. what i want to use is eval() to evaluate the variables i have in this html file. now my thinking is if i read this html into a string, addslashes, then there should be no problems in evaluating that. Maybe i am wrong in this please prove me wrong... but for some reason i cant. Also the code works in widows but not on my linux box. I dont see any difference in configurations in either.

 

and i tried your code and it gave me $width not 55.

maybe I should have said this before,  i am trying to purse an html file. in this file is only html. what i want to use is eval() to evaluate the variables i have in this html file. now my thinking is if i read this html into a string, addslashes, then there should be no problems in evaluating that. Maybe i am wrong in this please prove me wrong... but for some reason i cant. Also the code works in widows but not on my linux box. I dont see any difference in configurations in either.

 

and i tried your code and it gave me $width not 55.

PHP will parse any PHP code within any file that is being included, Provided you place all PHP code within PHP tags. So if your .html file is this:

<table width="<?php echo $width; ?>">

 

And you're using the the following code to include your .html file

<?php

$width = 55;

include 'myfile.html';

?>

The output will be

<table width="55">

 

You do not need to use output buffering/eval to parse the contents of an .html file that is being included.

ok I understand what everyone is telling me. maybe its me not explaining it correctly. I include it and it gives me the same thing, I eval it or i use ob_whatever it still gives me the samething. here is the questiong i should have asked: is there something that turns the function on and off or another function i could use or i dont know another trick some one can give me???

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.