Forum Moderators: phranque

Message Too Old, No Replies

PHP source files

AddType question

         

chrisjoha

1:10 pm on Sep 15, 2005 (gmt 0)

10+ Year Member



Hi, I have this in my httpd.conf -

AddType application/x-httpd-php-source .phps

But the source is showing up rather dull and grey. Is there an easy way to have source code color highlighted? (I though this directive would achieve the effect, but it only displays the code black'n'white)

jdMorgan

2:26 pm on Sep 15, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



"Dull and grey" is a client-side effect. You might want to look through the documentation of your client to see why this might be happening. An alternative would be to just use "text/plain" as the MIME-type.

Jim

chrisjoha

3:52 pm on Sep 15, 2005 (gmt 0)

10+ Year Member



I'm sure the server must be processing it, 'cause it takes a regular php file with the extension .phps and spits out this:

<code><span style="color: #000000">
function functionName() {
<br />&nbsp;&nbsp;&nbsp;&nbsp;global $vars;

and so on. Isn't it possible to make it add more rich formatting? I'm looking for something like the way code is presented in the php.net doc. I've seen it on .phps files many places, but don't remember any urls :(

coopster

4:20 pm on Sep 15, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



That is going to come out in b&w. If you were to add <?php ?> tags around the code in the file, you would probably see the syntax highlighting show up.

coopster

4:32 pm on Sep 15, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Also, the highlight.* directives in your php.ini will override the PHP defaults if you so desire. The defaults are typically:
; Colors for Syntax Highlighting mode. Anything that's acceptable in 
; <span style="color:?"> would work.
;highlight.string = #DD0000
;highlight.comment = #FF9900
;highlight.keyword = #007700
;highlight.bg = #FFFFFF
;highlight.default = #0000BB
;highlight.html = #000000

If you were to change one of them and uncomment it, for example ...
highlight.default = #CC00FF
... then you will notice that <?php ?> tags as well as function names would come out in pink rather than blue. More reading can be found in the PHP documentation.

[php.net...]

chrisjoha

8:04 am on Sep 16, 2005 (gmt 0)

10+ Year Member



Sorry, it's just me being a retard... I had cut out some code from a class to test, and of course I hadn't included the <?php?> around it... sorry

coopster

2:28 pm on Sep 16, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



No problem. That was the first thing I noticed when you posted a small chunk of your code there. The PHP delimiters are what triggers the engine to being coloring the code. Glad you got it sorted.