22
22
using namespace php ;
23
23
using namespace std ;
24
24
25
- void test ()
26
- {
25
+ void test () {
27
26
cout << " hello world" << endl;
28
27
}
29
28
30
- void md5test ()
31
- {
29
+ void md5test () {
32
30
echo (" [0]hash=%s\n " , md5 (" hello world" ).c_str ());
33
- echo (" [0]hash_hmac=%s\n " , hash_hmac (" ripemd160" , " The quick brown fox jumped over the lazy dog." , " secret" ).c_str ());
31
+ echo (" [0]hash_hmac=%s\n " ,
32
+ hash_hmac (" ripemd160" , " The quick brown fox jumped over the lazy dog." , " secret" ).c_str ());
34
33
35
34
Variant a (" hello world" );
36
35
echo (" [1]hash=%s\n " , php::exec (" md5" , a).toCString ());
37
36
echo (" [1]hash=%s\n " , php::exec (" md5" , " hello world" ).toCString ());
38
37
39
38
echo (" [1]hash_hmac=%s\n " ,
40
- php::exec (" hash_hmac" , " ripemd160" , " The quick brown fox jumped over the lazy dog." , " secret" ).toCString ());
39
+ php::exec (" hash_hmac" , " ripemd160" , " The quick brown fox jumped over the lazy dog." , " secret" ).toCString ());
41
40
}
42
41
43
- void testRedis ()
44
- {
42
+ void testRedis () {
45
43
cout << " =====================Test Redis==================\n " ;
46
44
Object redis = php::newObject (" redis" );
47
45
var_dump (redis);
48
46
auto ret1 = redis.exec (" connect" , " 127.0.0.1" , 6379 );
49
- // connect success
50
- if (ret1.toBool ())
51
- {
47
+ // connect success
48
+ if (ret1.toBool ()) {
52
49
auto ret2 = redis.exec (" get" , " key" );
53
50
printf (" value=%s\n " , ret2.toCString ());
54
- }
55
- else
56
- {
51
+ } else {
57
52
cout << " connect to redis server failed." << endl;
58
53
}
59
54
}
60
55
61
- void jsontest ()
62
- {
56
+ void jsontest () {
63
57
Array arr;
64
58
arr.append (1234 );
65
59
arr.append (1234.02 );
@@ -74,33 +68,28 @@ void jsontest()
74
68
var_dump (arr2);
75
69
}
76
70
77
- int main (int argc, char * argv[])
78
- {
71
+ int main (int argc, char *argv[]) {
79
72
php::VM vm (argc, argv);
80
73
String value = ini_get (" output_buffering" );
81
74
cout << " ENV:" << value.toInt () << endl;
82
75
83
76
Variant a = 1 ;
84
77
Variant b = 2 ;
85
78
86
-
87
79
auto c = a;
88
80
89
-
90
81
testRedis ();
91
82
92
83
include (" index.php" );
93
84
auto o = newObject (" test" );
94
-
95
85
var_dump (o);
96
- return 0 ;
97
86
98
87
Array url_params;
99
88
url_params.set (" name" , " rango" );
100
89
url_params.set (" value" , 1234 );
101
90
102
91
Array _arg_list;
103
- Object redis = php:: newObject (" redis" );
92
+ Object redis = newObject (" redis" );
104
93
_arg_list.append (redis);
105
94
106
95
Variant func = " var_dump" ;
@@ -109,18 +98,16 @@ int main(int argc, char * argv[])
109
98
auto url_query = http_build_query (url_params);
110
99
var_dump (url_query);
111
100
112
-
113
- // jsontest();
101
+ jsontest ();
114
102
md5test ();
115
- return 0 ;
116
103
117
104
vm.eval (" echo 'Hello World!';" );
118
- vm. include (" embed.php" );
105
+ include (" embed.php" );
119
106
120
- auto a = constant (" SWOOLE_BASE" );
121
- cout << " SWOOLE_BASE = " << a .toInt () << endl;
107
+ auto c1 = constant (" SWOOLE_BASE" );
108
+ cout << " SWOOLE_BASE = " << c1 .toInt () << endl;
122
109
123
- auto obj = php:: newObject (" Test" );
110
+ auto obj = newObject (" Test" );
124
111
auto ret = obj.exec (" getName" );
125
112
126
113
cout << ret.toString () << endl;
@@ -145,7 +132,5 @@ int main(int argc, char * argv[])
145
132
String s2 = s1.substr (0 , 5 );
146
133
cout << " s2=" << s2.c_str () << endl;
147
134
148
- // swoole_add_function("test", (void*) test);
149
-
150
135
return 0 ;
151
136
}
0 commit comments