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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:57:32+00:00 2026-06-04T21:57:32+00:00

I have my page contents saved in a database and would like to execute

  • 0

I have my page contents saved in a database and would like to execute any php code in the string. So if my string was:

<h1>Welcome</h1><?php echo $motto?><br/>

I only want to execute echo $motto. Using eval() will try to execute <h1>Welcome</h1>.

Any way to do 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-04T21:57:33+00:00Added an answer on June 4, 2026 at 9:57 pm

    Needless to say you should find another solution ASAP. In the meantime you can eval the code like this:

    $str = '<h1>Welcome</h1><?php echo $motto?><br/>'; // Your DB content
    
    eval("?> $str <?php ");
    

    Demo: http://codepad.org/ao2PPHN7

    I can’t stress that enough: eval is dangerous, and application code shouldn’t be in the database. Try a template parser like Smarty, Dwoo, or my favorite: Twig.

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

Sidebar

Related Questions

lets say i have two pages links.html & contents.php ... first page contains only
I have some html content stored in a database field. I would like trusted
I have the following code, which retrieves the page slugs from the database which
I have stored page contents (tables, plain text, images and paragraphs) into a variable.
I have this serious: I have ASP.NET page, This page contents Update panel with
Basically, I have a page of contents all placed in .box. What I need
On my web site I have XMLs with my page contents (automatically generated from
I have a page with 10 different div contents in it. Based on my
I have the contents of a web page assigned to a variable $html Here's
Hi I have a htmleditor like this: @{ ViewBag.Title = Home Page; } @Html.DevExpress().HtmlEditor(

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.