-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
test_string_quotation.php
51 lines (41 loc) · 1.14 KB
/
test_string_quotation.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
<?php
// require vender autoload
require_once('vendor/autoload.php');
// add namespace at the top
use Performance\Performance;
// preparation
$max = 5000000;
// single quotes no escape
Performance::point("'string single quotes'");
for ($i=0; $i < $max; $i++) {
$s1 = 'string single quotes';
}
Performance::finish();
// double quotes no dollar
Performance::point("\"string double quotes\"");
for ($i=0; $i < $max; $i++) {
$s2 = "string double quotes";
}
Performance::finish();
// single quotes escaped
Performance::point("'single quote \' escaped'");
for ($i=0; $i < $max; $i++) {
$s1 = 'single quote \' escaped';
}
Performance::finish();
// double quotes dollar
Performance::point("\"variable \$max is replaced\"");
for ($i=0; $i < $max; $i++) {
$s2 = "variable $max is replaced";
}
Performance::finish();
// double quotes dollar escaped
Performance::point("\"variable \\\$max is escaped\"");
for ($i=0; $i < $max; $i++) {
$s2 = "variable \$max is escaped";
}
Performance::finish();
// finish all tasks and show test results
Performance::results();
$export = Performance::export();
print_r('Tested assignment of ' . $max . ' strings' . "\n");