Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Format Source Code For Displaying On A Web Page


Is there a good function or plugin out there to format my source code examples?  I'm writing an article for a web page and want a very simple source code formatter.  Eg: code in black, comments in red, quoted items blue, key words green, class names bolded.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Displaying PHP Source Code
What dictates that .phps files display source code?

I have two examples, one where it all works as expected and one where it doesn't .... and it's really confusing.

CLI ( Command-line ) PHP Displaying Source Code In-line When Programis Executed
I'm using PHP 4.4.2, and use PHP on both the command-line and the web.

I am running PHP on SuSE 10 Linux , in a VMware 5.5 workstation, using
Apache 2.0.55 , on my Dell laptop. Everything has been running flawlessly
without problems. Very amazing to use VMware, it has worked beautifully.

uname -a

Linux xxxxxxx 2.6.13-15.8-default #1 Tue Feb 7 11:07:24 UTC 2006 i686 i686 i386
GNU/Linux

php -v
PHP 4.4.2 (cli) (built: Feb 7 2006 20:13:29)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies

php -m

[PHP Modules]
bcmath
bz2
calendar
ctype
curl
dbx
dio
domxml
exif
ftp
gd
gettext
gmp
iconv
mcrypt
mssql
mysql
ncurses
openssl
overload
pcre
posix
session
shmop
sockets
standard
sysvsem
sysvshm
tokenizer
wddx
xml
yp
zlib

When I run the following program from the command line it prints out the
source code as well as the output from the program. I run other PHP programs
on the command-line and this doesn't happen. It's really peculiar. The
error output is below.

I copied this off of php.net, and have modified it only slightly to allow
command-line input. I was trying to find a CSV solution, which I ended up
finding elsewhere, but am curious why this program would error out the
way it does--have I misconfigured something? My php.ini is basically
unchanged, if at all. I think I might have set the path to mysql but that's
about it. When I run this program from the web it works without error.

<?php

if ( $argv[0] )
{
$file = $argv[0] ;
}
else{
$file = $_GET['file'] ;
print "<font face=arial>
" ;
}

$row = 1;

$handle = fopen("$file", "r");

while ( ( $data = fgetcsv($handle, 1000, ",") ) !== FALSE )
{

$num = count($data);

print "$num fields in line $row:<br>
";

$row++;

for ($c = 0; $c < $num; $c++)
{
print "$data[$c]<br>
" ;

Displaying Html Code On PHP Generated Page
I am trying to create a link page in my php application. this is a page that will display a block of html code that a visitor can copy and paste into their web site to create a link back to mine. My PHP page has a line in it like this:

define('TEXT_INFORMATION', '<html page code is here>');

I have added the html code to create the page as noted above. the page contains a same of the banner image file and the html code that goes alon with it. My problem is that I haven't been able to "quote" the html code so that ir will not be executed.

every time I try to run the application from my web server my page will display two copies of the banner iimage not on banner image and text block like it should. Any suggestions?

Displaying Value As Epoch Format
I've been fiddling around and and come up with a solution for the current date
but when i try and display the results for the previous 5 days i am running into a slight
problem. This is what i have so far: PHP Code:

Displaying The Date In A Different Format!
I have a row called Date in the databse which is saved as 0000-00-00 When I try to echo it, it shows like that 2007-04-16 Maybe because I use this normal code: echo $row['Date']; How can I display it like that:16-04-2007

Display Source Code
What is the easiest way to display source code to the browser? I have designed a number of templates. I need to display PHP source code at the end of each template. So that anyone can simply click on the link and see the code of the current file.

Source Code Bug Or Feature?
I have just inherited someone elses PHP code and there is something strange
in it, at least to me. I'm wondering if I inherited a source code bug or is
it a PHP feature that I don't know about. This code is in "index.htm" and
the first few lines of the file look like:

<?
if($parm) {
more code
}
?>

Now, the error I am getting is that "$parm" is not defined. I would expect
that. Or is there some "hidden" way $parm can be defined and I just haven't
found the code that does it,

Documenting The Source Code?
i was wonderning what's the good way to document the source code? javadoc is nice idea but it get kinda messy... are there any other solutions available for php?

Source Code Security
I am trying to learn how to interact with mySQL using PHP pages, and all the examples I've seen require me to include my username, password, and database in my PHP code to establish the connection. What measures, if any, do I need to take to ensure that prying eyes will not be able to get into my source code and retrieve this info thereby enabling them to log into my database and mess with it?

How To Read Source Code
I downloaded the PHP 5 source code from
www.php.net web site. It is a tar compressed
file. I used WinZip to unzip it. Now I got a whole
bunch of files.

But I do not know to read these files. Do I use
Visual Studio, or any other IDE tools? Or do I
must use a text editor to open each file individually
to view it?

And, by the way, what is Zend? Is it a ( free ) IDE tool?

Hiding Source Code ?!
I have some php pages and some php+html tags in,pages. How can I hide my source codes in each one ? I know 1 way is to encrypt and encode them by some softwares like zend encoder or ... , but is there any other way to hide my source ?

Protect Source Code
Is it possible to hide a source code PHP in order to protect it,
I mean, I'm developpind a web solution for customers and I don't like that
the customer or the host see my code.

How Can I Encrypt The PHP Source Code?
I don't want anyone to check my code, is there anyway to encrypt the code? If so, do I need to configure Apache somehow to understand it?

Please Help View Php Source Code
i am trying to view the source code of a php page but when i view the page source it comes up with "&errormessage=Please fill in all fields and send again.&", i am trying to create a form to email box for my own website and have found one on a website i like, i am trying to get the php code but dont know how to get it to be displayed.

Hiding Php Code From Source
How do you create a line in html to call a php file instead of having the php typed out fully withing the html?

But i'd need to know two things, firstly im going to need to run php at different methods, these would be either the second the page loads the php would run or upon an action the code will run.

So basically i would have a html file + the php file seperate and then the html file calls up the php file. I currently have the html and php all in one note pad and it displays all my code in the page source.

Displaying .txt Files And Maintainint Their Format Using Php
I wish to display .txt files within a php page. I have found out how to do this but any formatting such as paragraphs and tabs is lost. Can anyone help me with how to display the txt file as it is, formatting included? It is simply so we can update our Community Centre website with ease via txt files.

Displaying Results From Database In A Particular Format
How do I display results from a database in a particular format.  For example the following text in this format including the lines in stored in the database:

Quote“Hello,

Welcome to the news for 11/06/07.

Thanks”
When I echo the results using the usual, <? echo $row_news[‘news’]; ?> it doesn’t echo the information in the database in the format it is stored for example it will display like this.  Quote“Hello, Welcome to the news for 11/06/07. Thanks”  How do I get it to display in the format it in displayed in the database?

Displaying Local Date In Specific Format
i'm trying to decide whether to use PHP or JavaScript to display a date on a website. what i'm wondering is where does PHP take the date from, the server or the client (ie will timezone become a factor). aswell as this, is there a simple way to allow the date to be displayed as: "22nd" "1st" or "14th" instead of "22" "1" or "14"?

Compile/crypt Php Source Code
I once read or heard someting about that you can compile your php script, is that just me mixing 2 things up, or is this true?

if it is, where can i read more about it, and has anyone tried it?

Shopping Cart Source Code
I need the php source code of a shopping Cart, Somebody knows of a good one?

Seeing The Source Code In Browser?
I just installed Apache 2.0.43 and PHP 4.4.0 on Win2000. I've been
advised to test the intallation by saving this script

<? phpinfo(); ?>

into a file called phpinfo.php in the server document root. (Which in
this case is C:/Program Files/Apache Group/Apache2/htdocs )

My book says all I have to do is "access this file via [my] web
browser" and I should see a fancy table, but all I see is the source
code. What could I be doing wrong?

Apache runs with the PHP module with no error message. This is a
stand-alone computer, so I set the servername to 127.0.0.1 --could that
be the problem? I was supposing that if I entered http://127.0.0.1 into
my browser address field, I should get the index.html file that's in
the htdocs directory, but I just get a not found. (I do have
DirectoryIndex index.html index.html.var in the httpd.conf) So it looks
like Apache isn't doing anything, or am I not seeing something?

PHP Code To Read A Web Page's Source
Does anybody know how one can supply a URL to a PHP script and have it search for specific code in that web page?

How To Properly Version Your Source Code... ?
That pretty much sums it up. I am looking for information or tips on
how to version your source code.

What I have always done is this:

major_build.minor_build.daily_build

major_build - I have never been involved with an application requiring a
major build.

minor_build - When I have coded the application to the point of
warranting a release, or a new release.

daily_build - Anytime I add a new feature, fix a bug, or finish a TODO
item. I do not however increase this number if I add a TODO. I do
however add it to a HISTORY log.

I'd love to know what professional programmers and commercial software
engineers (as in, anyone who worked in a collaborative commercial
project where version information may have been set by the company) do.

Community Calendar Code/source?
I would like to find a community calendar source for our 4H group to
use. I would like to to show the days of the month in a typical calendar
method and then have access for an administrative user to add events on
date/time with a title/description. If possible, an XML data file for
the dates or MS Access one....

PHP Code To Read A Web Page's Source
I want to read the page source of web page. Ex. http://www.phpfreaks.com I want to search for a string in its page source.

Retieve Remote Webpage Source Code
Let's say I have a remote page: www.website.com/somepage.html

How do I remotly view it's source code? By opening a socket and using GET header to recieve the source? Another way? I need it to be something like http://www.mysite.com/showsource.ph...m/somepage.html Is that possible at all?

Designing Source Code For Multiple Forms
I want to start writing a new site. It will include 3 forms that will
collect information from the user. I know how to keep the info in
sessions etc. my question is about the design of the server side php
files. I don't want to design all three forms in one big file, id
rather have a separate php file for each form.

Say I have a file form1.php which creates the initial form, should I
say (form1 action="form1.php") and have the form validation code in
form1.php? If so how do I call form2.php from inside form1.php? Or do I
say(form1 action ="form2.php") and have my validation code for form 1
inside form2.php if so how do I call back form1 if validation fails

now this has been asked already (see link below)and it was suggested to
use the include() require() functions. but then others have argued
against it. so is includeonce() the most practical way or should I
rather write all the code in to one big index.php

Local Source Code Search Engine?
I'm reviewing a clients application, and one of the things I need to do is verify every table in the databse is actually being used in the application.

I assumed one of my many PHP IDE's would be able to do this, but alas no, I can text search but I have hundreds of tables to verify, the application has over 1000 PHP pages and 350 database tables.

Any ideas? I started to write my own code search engine, thinking I could just dump the tablke names into it but getting the code into MySQL to search from was a lot more difficult then I expected (PHP doesnt like to submit PHP code .. even if you put it in XML).

Source Code Generated - But Still Blank Screen
This is a very odd problem I've run into and I currently have no idea what to do about it despite having looked over the code dozens of times.

I run an RPG online that, among other things, has a character creation system. Without going into any details of the system, I'm trying to add a feature that allows a member to change a skill of the character and reset the skill level of the new skill.

The function of the page may or may not be relevant. The code of the file first checks to see if username and password of the member are set. If they have been set, it checks the mysql database table for that combination. If it finds a record matching both, it generates the first page of the feature (giving a form in which to select skill to change and the new skill). If it doesn't find the record, it generates a page to display a typical "Login Incorrect" error page.

For testing purposes, I simply visit the page (passing username & password in through the URL) and it brings up a blank screen without any warnings or error messages. Upon viewing source, I see that it generated the "exact" html code in full that I wanted it to, but none of it is being displayed in the browser.

Opening Source Code Of A Remote Site
Basically I want to make a feed of sorts, but the site does not offer a feed, is there a way that I can take the source of a certain page then have a function that looks through the code for links and come out with just the links.

more or less i have an idea of how to do the search function, but i was wondering about the retrieving the other page, is it possible?  And if so, how?

Protecting Source Code On Mixed Html
How can I protect or block others from viewing my source code. I have a mixed form php and html, and someone has been trying to duplicate it. Each time they hit submit i get a text message on my phone, except all data is blank since they cannot connect to my database where all vars are stored.

How To Auto Prepend File To Show PHP Source Code
I know there is a auto_prepend option in php.ini. If I have a file like this: PHP Code:

PHP Question: 'hiding' Code On Server From View Source
I have just started figuring out PHP as a server-side approach to
something I did in Javascript.

I never was able to figure out CGI on a remotely hosted web server the
few times I tried (maybe wasnt' enabled?), but PHP is working fine...at
least no problems at all, not my usual experience.

What I would like to do is have the web page visitor access one page
that 'calls' another so that the code isn't visible thru a web
browser's 'View Source'.

Can a .php or .htm file in the 'public', 'www', or 'html' directory
access a .php file in for example the CGI-BIN area, or is there another
way to do this?

A visual example would probably help me more than a description.

How To Remove Specific Function Calls From Source Code...
I writing a lot of code that contains calls to my own Debug functions
(like log).
I want to produce a release from my code without this function calls,
so I tried to write a program that reads a source code and removes this
function calls with preg_replace...
And here is a problem. I can't write a proper regexp for this use.

There are some call that contains more that one argument or arguments
are created dynamicaly, like:

log($myVar1, $myVar2. " -". $myVar3, "(x:". $x .", y:". $y .")",
$arg1.'('.$arg2.');'.$arg3);

Adding Php Code Or To Include A Page With Php Code Into A .tpl Page
how would i do this, i am intergrating a phpbb forum system into my site!

Code To Display DB In A-Z Format
Anyone know of any PHP code that will take the data from a mySQL database and display in an A-Z format?

So in other words I have a database with 1800 records. I want to display all those records in alphabetical order with each letter on it's own page. Also creating an set of links like A B C D E ... on each page.

Get Page Source After Login
I want to get the source of a web page.
The problem is that this page is accessible only after I login, using
user name and password.
I wrote a simple script to get a page source and it works as long as no
login is necessary, but for the page I want I only get part of the
source, while part is missing. The missing part is with the personal
information.
I have my username and password, but I don't know how to send them in
the script, or what the other side is expecting.
(I know the site uses cookies, to store the session information.)

View The Source Of Another Page
From www.whatever.com/index.php how can I get the source for www.anothersite.com/page.php ?

Script Source Instead Of Web Page
What would be the problem that would cause Firefox to display the php source whereas IE displays the page fine? Web server is Apache on a Windows box.

Looking For A CVS File Format Manipulation Utility Or Code
I've used desktop software that allowed import or eport of data in
comma deliminated format and had a gui interface that easily allowed
columns to be reordered and deleted.

I could do this in spreadsheet but is there a stand-alone
utility of code I can imbed into an app for this?

How To Format Code In A SQL Query To Central Time ??
In the following string I have a system date and time that displays on a web page from the database. The problem I have is the web server is in a different time zone as I am.  Can someone tell me how to format this query to central time? Can this be done in MySQL? OR it has to be done in PHP?

   //gather the topics
   $get_topics_sql = "SELECT topic_id, topic_title, DATE_FORMAT(topic_create_time,  '%b %e %Y at %r') aS fmt_topic_create_time, topic_owner FROM forum_topics_reagan  WHERE topic_id = '".$_GET["topic_id"]."' LIMIT 1";

View The Source Of A Web Page Using A Script?
This is probably some really basic operation, but how do I view the source
of a web page using a php script.

For example I want to have a variable, say

$url = "www.google.com";

Then I want to echo its source code, so that I have a page showing:

<html>
<head><title>Whatever</title></head>
<body>
..
..
</body>
</html>

Problem Finding Source For Php Page
We have a page on our site and I have identified what should be the php file
on the server that generates it,

but when I change the file, the changes are not reflected in my browser
(after I refresh).

Displaying Parts Of A Page While The Page Is Not Complete Yet
A script I'm writing outputs a HTML table with many rows. Each row is the result of a query which takes about one minute to perform. When I run the script in a browser, the page takes several minutes to load and then displays the entire table. Is it possible (using PHP) to display the table as it gets constructed, one row at a time?

Displaying Code
I'm trying to build a help file for my web application that includes displaying some of the actual code in the app. Whenever I submit code to the database with form I'm using it behaves like its part of the application.

If the code is wrapped in <??> it doesn't even display on the web page. I tried using <? but when I update the record, it converts to <? and the code disappears again. Is there some code I can wrap everything in to display my script properly?

PHP Code Not Displaying In IE 6
I'm a newbie to PHP and am have problems getting simple PHP page
(php_test_page.php) to display correctly. The page is:

<html>

<body>

<H1>Test Line 1</h1>

<?PHP echo '<H1>Test Line 2</h1>' ?>

</body>

</html>

Test Line 1 displays fine by not the PHP line. If I look at the source with
the browser (IE 6), the line is still there.

I'm not sure if the following is the problem. I might have two problems
here. However, my default web server is not running and I can't seem to
start it. The following is the scenario with XP Professional:

- Click Control Panel

- Click Performance and Maintenance

- Click Administrative Tools

- Double Click Computer Management

- Open Services and Applications

- Open Internet Information Services

- Open Web Sites

- The "Default Web Site" is has a red error sign is marked as
stopped. Clicking "Default Web Site" and click "Start" yield an error dialog
with the following message. "Unexpected error 0x8ffe2740 occurred."

Displaying Table In Php Code
I have a PHP script that has a drop down to select a record, then it should display some text from a database and then display a table of information below it. But, the table is displaying at the top instead. Code:

Scrips Not Running, Only Displaying Code
I installed Apache, mySql, and php. I go to my server folder and run one of the php scripts that is needed to install oscommerce. IDK whats going on but the brower (firefox) will only display the code and won't run the actually script.

Formated Email Displaying HTML Code
I'm sending formatted emails that normally work fine, using the following header:

MIME-Version: 1.0

Content-type: text/html; charset=iso-8859-1

From: John Cook <jfoc@sev.com.au>


However, one person I send it to (unfortunately, the client I'm actually designing this email for) sees it as HTML code, no formatting. She does use MailMarshal, an email content filter. And the header in the returned email contained these lines:

X-AntiAbuse: This header was added to track abuse, please include it with any abuse report
X-AntiAbuse: Primary Hostname - elaine.networkeleven.net
X-AntiAbuse: Original Domain - hartleyfamilylaw.com.au
X-AntiAbuse: Originator/Caller UID/GID - [99 99] / [0 0]
X-AntiAbuse: Sender Address Domain - elaine.networkeleven.net

My question - would an email filter block HTML formatting? Should I do my header differently?


Copyright © 2005-08 www.BigResource.com, All rights reserved