Solved

How to make output display as compiled PHP

Posted on 2014-10-18
5
155 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

837 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