1<?php
2$myVar = "hello world!";
3
4var_dump($myVar);
5print_r($myVar);
6
7$allVars = get_defined_vars();
8print_r($allVars);
9debug_zval_dump($allVars);
10
11function sayHello($hello) {
12 echo $hello;
13 debug_print_backtrace();
14}
15
16sayHello($myVar);
17?>
1// ------ string -------
2// use echo, exit for output
3$a = 123
4echo ($a);
5exit;
6
7
8// ------ array -------
9$array = array(
10 1 => 'apple',
11 2 => 'banana',
12)
13
14// Method 1
15echo "<pre>";
16print_r($array);
17echo "</pre>";
18
19// Method 2
20echo "<pre>";
21var_dump($array);
22echo "</pre>";
23
24// Method 3 (no need exit) beacause of dd is already exit
25dd($array)
26
27// Method 4 (cakephp)
28pr ($array);
29
30
31// ------ json -------
32$json = {"a":"123"}
33
34pr (json_encode($json));
35exit;
36
37print_r (json_encode($json));
38exit;