-
Notifications
You must be signed in to change notification settings - Fork 2
/
source_include.php
49 lines (42 loc) · 1.83 KB
/
source_include.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
/**
* Show how to include source.php in a context.
*
* When you have a website with a header and footer you would most likely want to integrate the
* output of source.php in that context. You can then set some parameters and include source.php,
* as the result you will get the HTML than can be echoed out together with css-style information.
* This file is an example on how to do this. Read the comments in source.php to get a grip on
* the arguments used.
*
*/
// Include code from source.php to display sourcecode-viewer
$sourceBasedir=dirname(__FILE__); // Which directory to display
$sourceBaseUrl="?"; // What is the base url of of this script?
$sourceNoEcho=true; // Do not echo result, store in $sourceBody instead
$sourceNoIntro=true; // Do not display the intro, I want to write my own header and ingress
include("source.php");
$pageStyle=$sourceStyle; // $sourceStyle contains the CSS you need to present the HTML, put in HTML head.
$pageBody=$sourceBody; // The actual content of source.php, echo it out.
?>
<!DOCTYPE html>
<head>
<meta charset=utf-8>
<title>Example on integrating source.php in another context</title>
<style><?php echo $pageStyle; ?></style>
</head>
<body>
<p><em>Here I could include my own header.</em></p>
<h1>My own display of sourcecode</h1>
<p>Here it comes!</p>
<?php echo $pageBody; ?>
<hr>
<p><em>Here I could include my own footer.</em></p>
<p>
<a href="http://validator.w3.org/check/referer">HTML5</a>
<a href="http://jigsaw.w3.org/css-validator/check/referer">CSS</a>
<a href="http://jigsaw.w3.org/css-validator/check/referer?profile=css3">CSS3</a>
<a href="http://validator.w3.org/unicorn/check?ucn_uri=referer&ucn_task=conformance">Unicorn</a>
<a href="source.php?file=<?php echo $_SERVER['PHP_SELF'] ?>#file">Sourcecode</a>
</p>
</body>
</html>