473,503 Members | 7,214 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Placing PHP output in an HTML file.

66 New Member
This is probably some basic thing that I'm completely overlooking, but I have a PHP file that outputs some text. I'm going to use a simple file as an example:

[PHP]
<?php

$file = $_GET['file'];

highlight_file($file);

?>
[/PHP]

I'd like the highlighted code to show on an HTML page. Maybe a tag in which I could define the SRC to be "highlight.php?file=code.txt". I've tried iframes, but I'd like to avoid those.

Any ideas?
Jun 15 '07 #1
4 1760
pbmods
5,821 Recognized Expert Expert
Try using include. You can then output highlight.php directly into your page, rather than have the browser make two requests.
Jun 15 '07 #2
Motoma
3,237 Recognized Expert Specialist
What is the return value of highlight_file()? My suspicion would be that it is formatted HTML containing the source code for the file you specified. If this were the case, you would just print or echo it.
Jun 15 '07 #3
cheesecaker
66 New Member
Ah, nevermind, I solved it. The reason I was having problems was I couldn't figure out how to pass $_GET variables with include:

[PHP]<?php include('C:/Apache2.2/htdocs/textgen/highlight.php?file=textgen.php');?>[/PHP]

This does not work because PHP will search for a file named "highlight.php?file=textgen.php" on the local filesystem, which doesn't exist.

However, after reading php.net documentation, I learned that the only way to pass a script variables with $_GET is to use an HTTP address in the include statement. So:

[PHP]<?php include('www.example.com/textgen/highlight.php?file=textgen.php');?>[/PHP]

This does work. Thank you for the help, everyone.
Jun 15 '07 #4
Motoma
3,237 Recognized Expert Specialist
Glad you have found your solution. Thank you for posting it here, and come back anytime you have a question.
Jun 15 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
1865
by: Samantha | last post by:
Is there a limit on the size of the file Python will read then output. I am reading a file of 433 lines and when I output the same file it only will output 421 lines. The last line is cut off also....
1
5539
by: andy.t.chou | last post by:
I need to be able to have a hidden field (signiture) with each output html file generated. # (Get the first and last name from the html form) $first_name = $q->param('FirstN'); $last_name =...
2
2887
by: Bill Sneddon | last post by:
Can any one tell me how to output the following string? <%response.write "<tr><td><a href=""file://SERVER/mmlogs/TNAME" & yearmonth & """>"& "MYJUNK" & "</a><BR></td></tr>" %> ...
7
5058
by: Sherry Littletree | last post by:
Hi All I am working on a site that has a large amount of common html on all its web pages. I am looking for a way to place this in a single file so, if changes are made, I can change this...
5
7368
by: Poster | last post by:
I have a script, its outputs are in HTML. It displays perferctly in a browser, however when I view source, it gives me the JS scripts, but I want to view the HTML output. Is there a way I can view...
6
4247
by: Wescotte | last post by:
I'm writing a tiny php app that will log into our bank of america account and retrieve a file containing a list of checks that cleared the previous day. The problem I'm running into is when I...
4
1804
by: Stu | last post by:
Hi, I am writing a content management system that has to have W3C compliant output. The pages are template driven and there are special strings within the template to be used as placeholders for...
1
4341
by: Andrew | last post by:
I'm adding this as it to me a while to figure out all the pieces to be able to do this without using Microsoft.Office.Interop which caused me problems on the web-server. Streaming is the easy...
2
1249
by: alun65 | last post by:
I've been implementing some paging links that I would like at the bottom and top of a result set, I build up the required HTML in the code behind then add it to the placeholder. This works fine...
0
7207
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7093
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7291
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7357
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7012
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5023
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3180
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1522
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
402
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.