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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T10:13:39+00:00 2026-06-08T10:13:39+00:00

I have a variable which calls content from database, sample is below $content =

  • 0

I have a variable which calls content from database, sample is below

$content = '<div><h1>content here</h1>
<img src = 'image.jpg' /><br />

[code]echo 'welcome';[/code]

<h2>some content here</h2>
<p> some large content here</p>

[code]echo 'Click Here';[/code]

Thank you.';

echo 'headers here' .$content . 'footers here';

how can i execute PHP for the content in between [code] and [/code] tags?
remaining text would written as html execpt the codes used in [code] some php code [/code] tags

  • 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-08T10:13:42+00:00Added an answer on June 8, 2026 at 10:13 am

    If this is for a templateting type of system for your site I would suggest to go a different route.

    First your above code would change so that the portion between you code would look like:

    [code]{{msg}}}[/code]
    

    Now, you can still store your stuff in the database as php code if you want, but it makes more sense to eval it before you put it into the database, but I strongly suggest otherwise and go with a find/replace system.

    Now, you would want to have a function that would do the following:

    function output_template( $name, $data ) {
        $template_string = get_template_from_db( $name );
        for( $data as $k )
        {
            $template_string = str_replace( $k, $data[$k], $template_string );
        }
        return $template_string;
    }
    

    Then you can echo out the return value of this function. If you think you need to use eval, rethink what you are doing, especially for what appears to be a templating system.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a variable which I get from database I want to output this
I have variable which I populate from JSON formated data. Something like: var time=my_data[data.results[i].id].time;
I have a variable which contains 3 tag names which are separated from each
i have variable $lang which convert string to the selected language but i am
I have a variable which has to allow only numbers , dashes and parenthesis,
I have a variable which is referenced a lot. It started out as an
I have a variable which contains the value 1234567 . I would like it
I have a variable which has the directory path, along with the file name.
I have a variable which looks like xx-xx-xx-xx where each xx is a number
I have a variable which I need to strip of sybols before inserting into

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.