TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Absolute Beginners (http://www.talkphp.com/absolute-beginners/)
-   -   file_get_contents with PHP tags (http://www.talkphp.com/absolute-beginners/4074-file_get_contents-php-tags.html)

hello-world 03-25-2009 01:46 PM

file_get_contents with PHP tags
 
Hi I want to get the contents of a html + php with file_get_contents. As I print it, it prints the php tags like simple text. How can I get the php tags as php tags. I know my question is confusing. I hope you understand it.
Thanks in Advance.

xenon 03-25-2009 04:33 PM

You would use include or require to read the file.

hello-world 03-25-2009 06:19 PM

actually I use have a HTML (named profil.html) file which contains php coding inside.I used file_get_contents and parse it. The php codings is turned as string not as php script.
PHP Code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
        <link href="templates/default/stylesheet.css" rel="stylesheet" type="text/css"/></link>
        <title></title>
    </head>
    <body><div id="menu">{menu}</div>
        <div id="log">
    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" accept-charset="utf-8">

    <u><?php if(in_array("fill"$Nuser->error)) echo "<font color=red>Please fill all Fields</font>"?>
    <li>Name<input type="text" name = username>    <?php if(in_array("user"$Nuser->error)) echo "<font color=red>Wrong user</font>"?><?php if(in_array("taken"$Nuser->error)) echo "<font color=red>User taken</font>"?></li>

    <li>Password<input type="text" name = password>    <?php if(!empty($NoMatchedPass)){echo "passwords didn't matched";} ?><?php if(in_array("pass"$Nuser->error)) echo "<font color=red>Wrong user</font>"?></li>
    <li>Password<input type="text" name = password1></li>
    <li>Email<input type="text" name = email> <?php if(in_array("email"$Nuser->error)) echo "<font color=red>Wrong user</font>"?></li>
    <li><input type="submit" value="Register" name="submit"></li>
    </u>
</form>
</div>
    </body>
</html>


xenon 03-27-2009 06:17 PM

PHP Code:

ob_start();
extract($templateVarsEXTR_PREFIX_SAME'some_prefix_');
include 
'template_file.html';
$__parsed ob_get_contents();
ob_end_clean();

echo 
$__parsed

I forcedly used include there instead of include_once, for the case in which I need to include multiple template files, but with different contents (eg.: boxes of content).

hello-world 03-30-2009 08:32 PM

Actually I was using
this tutorial with some php tags in TBL/HTML Files. It was really hard to do that. So I just used include as you told me.
Thanks anyway


All times are GMT. The time now is 12:26 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0