Solved

How to make output display as compiled PHP

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

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 82

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 82

Expert Comment

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

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

707 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

13 Experts available now in Live!

Get 1:1 Help Now