TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   Display pages php code? (http://www.talkphp.com/general/2063-display-pages-php-code.html)

Aaron 01-23-2008 08:21 AM

Display pages php code?
 
Isn't there a function to display a page's source code, PHP and all? I know I've heard about it, but what is it?

I am going to try to use it for a tutorial, like one of those "type this code" things, so when you go in the browser you can see the php code and the output at the same time.

Orc 01-23-2008 09:13 AM

Err.. What do you mean by that? You cannot view PHP pages source code without an actual FTP, or anything like that.. Considering it's Server Side, I don't know what you want.. Do you want to get the contents of page? ???

Wait.. Is this remote? Or...?

Aaron 01-23-2008 09:38 AM

no, the coder is putting the code on the page.

Orc 01-23-2008 09:39 AM

Quote:

Originally Posted by Aaron (Post 9347)
no, the coder is putting the code on the page.

The coder is putting the source code on the page? ???

You mean like apps where a user saves some code and its put into a database, and it displays it on the main page?

EyeDentify 01-23-2008 09:40 AM

maybe this is what your looking for:

highlight_string():
PHP: highlight_string - Manual

highlight_file():
PHP: highlight_file - Manual

Good luck!

/EyeDentify

Aaron 01-23-2008 09:48 AM

That isn't it... I guess I was wrong about the function.

I can always say "copy and paste into a textarea" :/

Orc 01-23-2008 09:50 AM

I still don't understand what you're trying to accomplish, and I'm asleep here(I say that a lot cause well, time is too fast :P)

sjaq 01-23-2008 11:38 AM

Maybe you mean some kind of in-browser command line interface? That's pretty easy to make with AJAX and php..

Aaron 01-23-2008 12:14 PM

Quote:

Originally Posted by Aaron (Post 9342)
Isn't there a function to display a page's source code, PHP and all? I know I've heard about it, but what is it?

I don't know how much clearer I can get. If you don't understand that I am screwed.

Wildhoney 01-23-2008 01:38 PM

My answer to that would be exactly the same as EyeDentify's answer. That displays source code, PHP and all.

Gareth 01-23-2008 02:01 PM

You could change the extension to .phps ??

sarmenhb 01-24-2008 04:38 AM

if your making a tutorial and want to display a peice of code in like a scroll bar you can just use good 'ol html. something like this

Code:


<style type="text/css">

div {
        height: 30em;
        width: 25em;
        padding: 1em 1em 0 1em;
        overflow: auto;
        background: #fff;
        border: 1px solid #999;
    }

</style>


<body>

<div>

<pre>
the text in here will be displayed in a box with scroll bars
</pre>

</div>

</body>

the <pre> tag is what allows you to display code to the page.

wGEric 01-24-2008 11:45 PM

Quote:

Originally Posted by Aaron (Post 9342)
I am going to try to use it for a tutorial, like one of those "type this code" things, so when you go in the browser you can see the php code and the output at the same time.

highlight_file will do what you want. Create a page with your tutorial and then whenever you have source code, create a separate file for the source code. Use that function to put the source code in your tutorial and have a link to see the file run.

If you want this all in the same file then where you want to have the code displayed you'll have to write out the code so it can be displayed. Where you want the results to be displayed, then you write the code so that it is executable and it outputs the results.

DeMo 01-30-2008 02:36 PM

I think I know what he is talking about...
Go to php.net, scroll the page all the way down to the footer and you'll see this link: show source, click it and it will show the source code of that page. This link is clickable in all pages of the site.

Alan @ CIT 01-30-2008 02:45 PM

And if anyone wants to do the same on their site, it even gives you the source for the source viewer :-) PHP: Show Source

Alan

DeMo 01-30-2008 02:48 PM

Looking at the source one can see that there's no secret, they're using the highlight_php() function too. :)

Aaron 01-31-2008 11:29 AM

Thanks! :P When you said highlight_file, it didn't sound familiar, but I guess it was the thing that I was looking for.


All times are GMT. The time now is 05:29 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0