Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

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

Posts: 340
Name: Jon
Location: New York
Trades: 0
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
Dev Machine:: Apache 2.2.6 PHP 5.2.6 MySQL 5.1
amw_drizz is offline
Reply With Quote
View Public Profile Visit amw_drizz's homepage!
 
 
Register now for full access!
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,111
Name: Matt. (>',')>
Location: London, England.
Trades: 0
highlight_file() is the function you will need.
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
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: 340
Name: Jon
Location: New York
Trades: 0
thanks that is what i was looking for
__________________
AMW_Drizz
Dev Machine:: Apache 2.2.6 PHP 5.2.6 MySQL 5.1
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: 462
Name: Jerod Lycett
Location: /home/arenlor
Trades: 0
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: 340
Name: Jon
Location: New York
Trades: 0
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
Dev Machine:: Apache 2.2.6 PHP 5.2.6 MySQL 5.1
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: 462
Name: Jerod Lycett
Location: /home/arenlor
Trades: 0
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: 340
Name: Jon
Location: New York
Trades: 0
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
Dev Machine:: Apache 2.2.6 PHP 5.2.6 MySQL 5.1
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
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
http://code.google.com/p/orangevolt-syntax-highlight/
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to PHP Code Block??
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB 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.65137 seconds with 12 queries