Click to See Complete Forum and Search --> : php positioning


DJAraym
01-28-2006, 08:56 PM
how do u position to certain pixels php source code :/

NogDog
01-28-2006, 09:10 PM
Could you give more of an explanation? I'm not sure if you mean you have a PHP page whose output needs to have its positioning adjusted, or if you are trying to display the source code for a PHP script on a HTML page and want to control the positioning of that text. Or perhaps a 3rd alternative I haven't thought of?

DJAraym
01-29-2006, 11:46 AM
yes its a php source code poll source code of php tryin to be positioned in html text file hopefully that explains it :rolleyes:

NogDog
01-29-2006, 12:09 PM
Here's an example PHP file that will display the source of another file, formatted to keep any white-space within that source code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang='en'>
<head>
<META HTTP-EQUIV='Content-Type' CONTENT='text/html; charset=ISO-8859-1'>
<title>Page title</title>
<style type="text/css">
.code {
font: medium courier, monospace;
white-space: pre;
padding: 0.5em;
background-color: #ddd;
color: black;
border: solid 1px black;
overflow: auto;
}
</style>
</head>
<body>
<?php
$file = "debug.php"; // file whose source code is to be displayed
$code = @file_get_contents($file); // read contents of file
if($code != FALSE)
{
echo "<div class='code'>"; // use our "code" CSS class
echo htmlentities($code); // replace special HTML chars with entities
echo "</div>\n";
}
else // failed to read file
{
echo "<p>ERROR: failed to read file '$file'.</p>\n";
}
?>
</body>
</html>