Solved

How to make output display as compiled PHP

Posted on 2014-10-18
5
149 Views
Last Modified: 2014-10-18
I have queried my database and output the field named "code_output". It is my intention for this field to hold html and php. When it displays, the html compiles and displays correctly, but the php does not compile. It literally shows the php code.

In other words, it will output, <table border="1"><tr><td>test</td></tr></table> AS AN ACTUAL TABLE

But when I use, <?php echo "test"; ?>, It doesn't compile, It LITERALLY DISPLAYS <?php echo "test"; ?>

How can I display the query and output as compiled php?

Tis is the simple line of code:
echo $code_output;
0
Comment
Question by:edavo
  • 3
  • 2
5 Comments
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 40389642
I don't believe that you can.  Since the data that your query returns is Not part of the PHP file, it is simply handled as text.  It is not passed to the PHP interpreter to be 'executed'.
0
 

Author Comment

by:edavo
ID: 40389643
So there's no "simple" way to have an online php editor/tester - like a JS fiddle?
0
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 40389656
Right, no "simple" way.  This search https://www.google.com/search?q=php+online+editor will list a number of 'online' PHP editors but "simple" is not what I would call them.  This one http://www.compileonline.com/execute_php_online.php looks interesting.  Since PHP is capable of accessing the files on the server, an application like that has to create a "sandbox" to restrict the operation of PHP to a safe environment that can't damage the server.
0
 

Author Comment

by:edavo
ID: 40389658
Gotcha - thank you very much…
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 40389660
You're welcome, glad to help.
0

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Foreword In the years since this article was written, numerous hacking attacks have targeted password-protected web sites.  The storage of client passwords has become a subject of much discussion, some of it useful and some of it misguided.  Of cou…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now