2222using namespace php ;
2323using namespace std ;
2424
25- void test ()
26- {
25+ void test () {
2726 cout << " hello world" << endl;
2827}
2928
30- void md5test ()
31- {
29+ void md5test () {
3230 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 ());
3433
3534 Variant a (" hello world" );
3635 echo (" [1]hash=%s\n " , php::exec (" md5" , a).toCString ());
3736 echo (" [1]hash=%s\n " , php::exec (" md5" , " hello world" ).toCString ());
3837
3938 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 ());
4140}
4241
43- void testRedis ()
44- {
42+ void testRedis () {
4543 cout << " =====================Test Redis==================\n " ;
4644 Object redis = php::newObject (" redis" );
4745 var_dump (redis);
4846 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 ()) {
5249 auto ret2 = redis.exec (" get" , " key" );
5350 printf (" value=%s\n " , ret2.toCString ());
54- }
55- else
56- {
51+ } else {
5752 cout << " connect to redis server failed." << endl;
5853 }
5954}
6055
61- void jsontest ()
62- {
56+ void jsontest () {
6357 Array arr;
6458 arr.append (1234 );
6559 arr.append (1234.02 );
@@ -74,33 +68,28 @@ void jsontest()
7468 var_dump (arr2);
7569}
7670
77- int main (int argc, char * argv[])
78- {
71+ int main (int argc, char *argv[]) {
7972 php::VM vm (argc, argv);
8073 String value = ini_get (" output_buffering" );
8174 cout << " ENV:" << value.toInt () << endl;
8275
8376 Variant a = 1 ;
8477 Variant b = 2 ;
8578
86-
8779 auto c = a;
8880
89-
9081 testRedis ();
9182
9283 include (" index.php" );
9384 auto o = newObject (" test" );
94-
9585 var_dump (o);
96- return 0 ;
9786
9887 Array url_params;
9988 url_params.set (" name" , " rango" );
10089 url_params.set (" value" , 1234 );
10190
10291 Array _arg_list;
103- Object redis = php:: newObject (" redis" );
92+ Object redis = newObject (" redis" );
10493 _arg_list.append (redis);
10594
10695 Variant func = " var_dump" ;
@@ -109,18 +98,16 @@ int main(int argc, char * argv[])
10998 auto url_query = http_build_query (url_params);
11099 var_dump (url_query);
111100
112-
113- // jsontest();
101+ jsontest ();
114102 md5test ();
115- return 0 ;
116103
117104 vm.eval (" echo 'Hello World!';" );
118- vm. include (" embed.php" );
105+ include (" embed.php" );
119106
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;
122109
123- auto obj = php:: newObject (" Test" );
110+ auto obj = newObject (" Test" );
124111 auto ret = obj.exec (" getName" );
125112
126113 cout << ret.toString () << endl;
@@ -145,7 +132,5 @@ int main(int argc, char * argv[])
145132 String s2 = s1.substr (0 , 5 );
146133 cout << " s2=" << s2.c_str () << endl;
147134
148- // swoole_add_function("test", (void*) test);
149-
150135 return 0 ;
151136}
0 commit comments