Reply
PHP Code Block??
Old 11-17-2007, 02:08 PM PHP Code Block??
amw_drizz's Avatar
Ultra Talker

Posts: 301
Name: Jon
Location: New York
Okay i am working on a website which will display small snippets of php code and allow people to download the complete version, or depending on size just display the whole php code.

What i am trying to find out is how to create the code block on normal PHP/HTML pages which will show the php code in syntax coloring if that is what you call it.

PHP Code:
<?php 
echo "kinda like this"
?>
__________________
AMW_Drizz
Php 5.2 Mysql 4.1 IIS 6 Win2k3 Server && PHP 5.2 MySQL 4.1 Apache 2.2 (separate machine of course)
amw_drizz is offline
Reply With Quote
View Public Profile Visit amw_drizz's homepage!
 
When You Register, These Ads Go Away!
Old 11-17-2007, 03:32 PM Re: PHP Code Block??
stOx's Avatar
Machine

Latest Blog Post:
Worlds Smallest Car - Peel P50
Posts: 2,114
Name: Matt. (>',')>
Location: London, England.
highlight_file() is the function you will need.
stOx is offline
Reply With Quote
View Public Profile Visit stOx's homepage!
 
Old 11-17-2007, 04:23 PM Re: PHP Code Block??
amw_drizz's Avatar
Ultra Talker

Posts: 301
Name: Jon
Location: New York
thanks that is what i was looking for
__________________
AMW_Drizz
Php 5.2 Mysql 4.1 IIS 6 Win2k3 Server && PHP 5.2 MySQL 4.1 Apache 2.2 (separate machine of course)
amw_drizz is offline
Reply With Quote
View Public Profile Visit amw_drizz's homepage!
 
Old 11-18-2007, 10:13 AM Re: PHP Code Block??
Arenlor's Avatar
Ultra Talker

Posts: 463
Name: Jerod Lycett
Location: /home/arenlor
Also note there is a highlight_string()
Arenlor is offline
Reply With Quote
View Public Profile Visit Arenlor's homepage!
 
Old 11-18-2007, 11:36 AM Re: PHP Code Block??
amw_drizz's Avatar
Ultra Talker

Posts: 301
Name: Jon
Location: New York
the way i am setting it up is like so
cause i am putting the info i want to call for the display in the array, just set it up with the test to make sure it works right.

PHP Code:
<?php
$code 
$_GET['code'];
$code_array = array(
                
'test' => 'code/test.php',
                );
if(!
$code || !array_key_exists($code,$code_array)){
include(
'pages/code/list.php');
define('stop','stop');
}
else {
$getcode $code_array$code ];
}

if(!
defined('stop') == 'stop'){ ?>
<style type="text/css">
<!--
.style1 {color: #FFFFFF}
-->
</style>
<p>This Code is avalible for free, just keep the Copywrite in Place</p>
<p> <?php 
echo 'The Code File Selected is: ';
echo 
$_GET['code'];
?></p>
<iframe src="pages/dispcode.php?code=<?php echo $getcode ?>" name="CodeBlock" width="650" height="600" scrolling="auto" frameborder="1" class="style1">
TEXT FOR NON-COMPATIBLE BROWSERS HERE</iframe>
<?
}
?>
__________________
AMW_Drizz
Php 5.2 Mysql 4.1 IIS 6 Win2k3 Server && PHP 5.2 MySQL 4.1 Apache 2.2 (separate machine of course)
amw_drizz is offline
Reply With Quote
View Public Profile Visit amw_drizz's homepage!
 
Old 11-18-2007, 11:58 AM Re: PHP Code Block??
Arenlor's Avatar
Ultra Talker

Posts: 463
Name: Jerod Lycett
Location: /home/arenlor
I don't know arrays (just never learned them) so I'm not sure if it'll work or not, do you have a working example anywhere?
Just a touch of knowledge here:
echo 'The Code File Selected is: ';
echo $_GET['code'];
Can be shortened to:
echo 'The Code File Selected is: '.$_GET['code'];
__________________
PHP Code:
<?php echo "Hello World"?>
HTML Code:
<html><head><title>Hello World</title></head><body><p>Hello World</p></body></html>
Arenlor is offline
Reply With Quote
View Public Profile Visit Arenlor's homepage!
 
Old 11-18-2007, 12:29 PM Re: PHP Code Block??
amw_drizz's Avatar
Ultra Talker

Posts: 301
Name: Jon
Location: New York
i have a working example on this computer running on my apache 2.2 web server. i dont have it uploaded anywhere on the net though.
__________________
AMW_Drizz
Php 5.2 Mysql 4.1 IIS 6 Win2k3 Server && PHP 5.2 MySQL 4.1 Apache 2.2 (separate machine of course)
amw_drizz is offline
Reply With Quote
View Public Profile Visit amw_drizz's homepage!
 
Old 11-18-2007, 12:36 PM Re: PHP Code Block??
chrishirst's Avatar
Super Moderator

Posts: 13,669
Location: Blackpool. UK
http://code.google.com/p/orangevolt-syntax-highlight/
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to PHP Code Block??
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.15082 seconds with 12 queries