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 7827585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T09:56:50+00:00 2026-06-02T09:56:50+00:00

I am using PHP in combination with Smarty Templates to generate pages serverside. Currently,

  • 0

I am using PHP in combination with Smarty Templates to generate pages serverside. Currently, I am loading a page as follows:

$smarty->assign('app', file_get_contents("some_content.php"));

Where some content contains HTML with PHP tags and code inside those tags.

I would like the PHP content inside this file within the current scope (That of the script reading the file), so that a particular function I’ve defined is available. How would I go about doing so? All the information I can find is regarding the eval(…) function, which doesn’t seem to be able to cope with the HTML/PHP mixture: would I need to perform a find/eval/replace operation to achieve the desired result, or is there a more elegant way of doing this?

  • 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-02T09:56:56+00:00Added an answer on June 2, 2026 at 9:56 am

    From my opinion, this short snippet of the code you posted shows that something is generally wrong there 🙂

    But nevertheless you can achieve whatever you are trying to achieve by doing the following:

    ob_start();
    include("some_content.php");
    $result = ob_get_clean();
    $smarty->assign('app', $result);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently using a combination of PHP, ORACLE, PDO, and JNDI to connect
I'm using a combination of PHP and Phonegap. I use PHP to build the
I'm using the combination of json_encode (PHP) and JSON.parser (Javascript from json.org) for passing
I am trying to make a search function using the combination of DOM, PHP
I'm using a compination of actionscript's getPixel and php's imagecreatetruecolor and imagesetpixel to generate
Using Php I would like to extract the current Url of a page including
I am using a combination of PHP, jQuery and Spry to serve a series
I'm using the ajax technique in combination with php and I want to know
Is there a way to check a valid host:port combination using regex and php?
I'm using a combination of Paul Duncans php ZipStream ( http://pablotron.org/software/zipstream-php/ ) on the

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.