Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9299031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T22:28:00+00:00 2026-06-18T22:28:00+00:00

Basically, I can write html tags/text etc etc to the file. All that is

  • 0

Basically, I can write html tags/text etc etc to the file. All that is fine. However, I need to be able to write some actual php into the file and I’m completely oblivious of how I should go about doing this.

Anyway here is what I have got to help better demonstrate my situation:

$path = substr(md5(time() . md5(rand())), 0, 8);
$dir = substr(md5($_SERVER['REMOTE_ADDR']), 0, 4);
$fpath = "b/" . $dir "/" . $path;
$file = 'index.php';

$handle = fopen($fpath . '/' . $file, 'w') or die ('cannot create the file'); 
include template.php;
fwrite($handle, $pt1 . $pt2 . $pt3);

Inside the template.php I have variables holding a lot of html in $pt1,$pt2,$pt3
But, inbetween each ‘pt’ I need to have some actuall php.

So for example sake say I need $this inbetween each ‘pt’ and the $this being:

<?php 
if(isset($_SESSION['user'])){
echo "hello";
}else{
echo "bye";
} 
?>

How would I do it?

*The actual creating of the file and paths is fine though but, I know that it may look very unusual however, I like it that way. It’s simply adding the php scripts to the php file.

  • also I have tried sticking the scripts inside variables but, it seems to just print them out as plain text in the file rather than executing them.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T22:28:01+00:00Added an answer on June 18, 2026 at 10:28 pm

    Does inbetween each pt means $p1 . $var . $pt2?

    Try something like this:

    <?PHP
    $var = '<?php 
    if(isset($_SESSION["user"])){
    echo "hello";
    }else{
    echo "bye";
    } 
    ?>';
    echo $pt1 . $var . $pt2;
    ?>
    

    Edit:

    Also, you can wrap long content into a variable using

    <?PHP
    $var = <<< 'PHP'
    <?php 
    if(isset($_SESSION["user"])){
    echo "hello";
    }else{
    echo "bye";
    } 
    ?>
    PHP;
    $pt1 = 'before';
    $pt2 = 'after';
    echo "$pt1 $var $pt2";
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to write a function that can project some location defined by latitude/longitue
can anyone help me write a linq query, its a bit confusing... Basically i
I keep reading that object-oriented programming can basically be done in any programming language,
Hi All I am havinga problem with Entity framework, basically as you can see
How can I make a NSAttributedString that would basically be a horizontal separator, like
I'm currently supporting a legacy python application that generates all the html through creating
I need to generate a html form with different hidden variables . However the
HellO, I want to write a binary file format viewer for windows which can
I'm basically trying to setup my own private pastebin where I can save html
I've been following the tutorial at http://iphonebyradix.blogspot.com/2011/03/read-and-write-data-from-plist-file.html showing how to extract data from a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.