9 Replies - 472 Views - Last Post: 12 December 2012 - 03:14 PM Rate Topic: -----

#1 Jezzabeanz  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 35
  • Joined: 19-September 11

Displaying all code dymanically

Posted 12 December 2012 - 09:48 AM

Hi,
For my Database-Driven Websites project I have had to make a dynamic website. One of the requirements is I need a hyperlink to display the code used on each page.

Is there a method to do this requiring as little coding as possible?

Thanks
Is This A Good Question/Topic? 0
  • +

Replies To: Displaying all code dymanically

#2 BenignDesign  Icon User is offline

  • holy shitin shishkebobs
  • member icon




Reputation: 5937
  • View blog
  • Posts: 10,346
  • Joined: 28-September 07

Re: Displaying all code dymanically

Posted 12 December 2012 - 09:50 AM

With as little code as possible, you could use <code></code> tags.
Was This Post Helpful? 0
  • +
  • -

#3 Jezzabeanz  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 35
  • Joined: 19-September 11

Re: Displaying all code dymanically

Posted 12 December 2012 - 09:54 AM

This doesn't work with PHP. Anything else? :neat:
Was This Post Helpful? 0
  • +
  • -

#4 BenignDesign  Icon User is offline

  • holy shitin shishkebobs
  • member icon




Reputation: 5937
  • View blog
  • Posts: 10,346
  • Joined: 28-September 07

Re: Displaying all code dymanically

Posted 12 December 2012 - 09:56 AM

Well, what have you tried so far?
Was This Post Helpful? 0
  • +
  • -

#5 Jezzabeanz  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 35
  • Joined: 19-September 11

Re: Displaying all code dymanically

Posted 12 December 2012 - 09:59 AM

I was going to use a jQuery popup.
Perhaps if I go through the PHP and change the "<?php ?>"
to &lt;?php ?&gt; and place it within the code tags and then place it within the div.
Was This Post Helpful? 0
  • +
  • -

#6 BenignDesign  Icon User is offline

  • holy shitin shishkebobs
  • member icon




Reputation: 5937
  • View blog
  • Posts: 10,346
  • Joined: 28-September 07

Re: Displaying all code dymanically

Posted 12 December 2012 - 10:03 AM

Give it a shot. If it doesn't work, we'll still be here.
Was This Post Helpful? 0
  • +
  • -

#7 no2pencil  Icon User is offline

  • Toubabo Koomi
  • member icon

Reputation: 5191
  • View blog
  • Posts: 26,901
  • Joined: 10-May 07

Re: Displaying all code dymanically

Posted 12 December 2012 - 10:08 AM

View PostJezzabeanz, on 12 December 2012 - 11:48 AM, said:

Is there a method to do this requiring as little coding as possible?

You shouldn't be thinking in this mindset. Code to get it done, not to get it done as easily as possible.

You need to get over the idea of technologies being judged by difficulty. It takes what it takes to get done. If you want simple, stick to working in wordpress (or another wysiwig) & don't take on coding projects.
Was This Post Helpful? 4
  • +
  • -

#8 CTphpnwb  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 2896
  • View blog
  • Posts: 10,031
  • Joined: 08-August 08

Re: Displaying all code dymanically

Posted 12 December 2012 - 10:40 AM

View PostJezzabeanz, on 12 December 2012 - 12:59 PM, said:

I was going to use a jQuery popup.
Perhaps if I go through the PHP and change the "<?php ?>"
to &lt;?php ?&gt; and place it within the code tags and then place it within the div.

I prefer using pre. showcode.php:
<?php
$filename = "showcode.php";
$data = htmlentities(file_get_contents($filename));
echo "<pre>".$data."</pre>";
echo "<br><br>";
echo "<code>".$data."</code>";
?>

This post has been edited by CTphpnwb: 12 December 2012 - 10:41 AM

Was This Post Helpful? 3
  • +
  • -

#9 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6039
  • View blog
  • Posts: 23,437
  • Joined: 23-August 08

Re: Displaying all code dymanically

Posted 12 December 2012 - 10:57 AM

Or, highlight_file()
Was This Post Helpful? 2
  • +
  • -

#10 creativecoding  Icon User is offline

  • Hash != Encryption
  • member icon


Reputation: 926
  • View blog
  • Posts: 3,204
  • Joined: 19-January 10

Re: Displaying all code dymanically

Posted 12 December 2012 - 03:14 PM

You can use file_get_contents (like in CTphpnwb's example) to retrieve the actual PHP source of a file without having it execute first.

Also that highlight_file is amazing, I've didn't know that existed until now and it's pretty awesome.

It'd be a big security hole, but you can create a single script using either of the above examples and then use a GET variable for the file. For more security you can limit what directories the user can view.

With something like that you can do your jquery popup. It would have to fetch that page though, your task would be impossible using javascript alone.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1