forked from brandonwamboldt/php-highlighter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sample.php
executable file
·178 lines (151 loc) · 3.79 KB
/
sample.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<?php
/**
* PHPLighter
*
* A PHP syntax highlighting engine the utilizes token_get_all() to produce a
* level of syntax highlighting that rivals any modern editor. No more barebone
* generic syntax highlighting!
*
* NOTICE OF LICENSE
*
* Licensed under the Open Software License version 3.0
*
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
* http://opensource.org/licenses/OSL-3.0
*
* @package phplighter
* @author Brandon Wamboldt <brandon.wamboldt@gmail.com>
* @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* @link http://brandonwamboldt.ca/phplighter
* @since 1.0.0
*/
// Namespaces
namespace Content\Sample\Files;
use Vendor\Library\Router;
/**
* This is a very simple abstract class, loosely based off code I wrote for my
* Router available at brandonwamboldt.ca. This isn't real code and shouldn't
* be used for any projects
*
* @author Brandon Wamboldt <brandon.wamboldt@gmail.com>
*/
abstract class AbstractClass
{
/**
* This is a protected property
*
* @var string
*/
protected $foo;
/**
* This is another protected property
*
* @var string
*/
protected $bar = 'string value';
/**
* Random variables just to test syntax highlighting
*/
private $baz = 12345;
private $bz;
public $routes;
public $music = FALSE;
public $value = TRUE;
public $nil = NULL;
public $arr = array();
public $farr = array( 'value1', 'value2', 'value3', 'key1' => 'value4', 5 => 'value5', TRUE, FALSE, NULL );
// Static variables
public static $myvar;
public static $yourvar = 'Your value';
const PI = '3.14159';
/**
* This is a function (Magic method)
*/
public function __construct( $param1, $param2 = array(), $param3 = 5, $param4 = '', MagicType $param5 )
{
global $fakevar;
// If statement checks + print/echo/string checks
if ( $param1 === 5 && $param2 == 'string' ) {
echo 'hello world';
} else if ( $param1 == 6 ) {
print 'hello \ \\ \' world';
} elseif ( $param1 == 7 ) {
echo "hello {$this->bar}, welcome!" . "Another value {$param3} over here";
}
// Variable assignment
$var1 = 1;
$var2 = '';
$var3 = "";
$var4 = 'Hello World';
$var5 = TRUE;
$var6 = FALSE;
$var7 = NULL;
$var8 = (array) array( 'a', 'b', 'c', 'd', 'e' );
$var9 = 51.5;
$abc1 &= $var1;
unset( $abc1 );
// PHP functions
$var1 = explode( '|', 'a|b|c|d|e|f|g' );
$var2 = implode( '|', $var1 );
$var3 = array_merge( $var8, array( 'f', 'g' ) );
// Eval
eval( "<?php echo 'hello world'; ?>" );
// Exec
`ls /etc`;
exec( 'ls /etc/' );
if ( 256 & 64 ) {
# Bitwise and
} else if ( 128 | 32 ) {
# Bitwise or
}
// Try catch
try {
throw new Exception( 'OH NOES, AN EXCEPTION!', 16525 );
} catch( Exception $e ) {
}
// Foreach loops
foreach ( $var8 as $key => $val ) {
echo $key;
}
// For loop
for ( $i = 0; $i < 100; $i++ ) {
echo $i . '<br />';
}
// While loop
while ( $i > 0 ) {
$i--;
}
// Switch statement
switch ( 'hello' ):
case 'hi':
break;
case 'hey':
case 'hay':
echo 'hey is for horses';
break;
default:
# Do stuff
endswitch;
# Magic constants
echo __CLASS__;
echo __NAMESPACE__;
echo __FILE__;
echo __DIR__;
echo __FUNCTION__;
// If statement
if ( $var1 and $var2 or $var3 ) {
}
}
/**
* Static method
*/
final public static function bar()
{
echo self::$myvar;
}
}
class RealClass extends AbstractClass implements ClassInterface
{
}