import source from 1.3.40
[external/swig.git] / Examples / php / variables / runme.php4.old
1 <?php
2 ### THIS VERSION was written for when php global vars fakingly mirrored
3 ### the wrapped global vars, but it was very inefficient.
4 ### For now we don't do this (pending some changes to php itself) so
5 ### we use accessor functions instead; WE KEEP THIS version around ready
6 ### for when those php changes are made and we can switch back.
7 ### Specifically we want $_GLOBALS variable overloading like object 
8 ### property overloading
9
10         require "example.php";
11
12         /* Try to set the values of some global variables */
13
14         $ivar = 42;
15         $svar = -31000;
16         $lvar = 65537;
17         $uivar = 123456;
18         $usvar = 61000;
19         $ulvar = 654321;
20         $scvar = -13;
21         $ucvar = 251;
22         $cvar = "S";
23         $fvar = 3.14159;
24         $dvar = 2.1828;
25         $strvar = "Hello World";
26         $cstrvar = "Goodbye";
27         $iptrvar = new_int(37);
28         $ptptr = new_point(37,42);
29         $name = "Bill";
30
31         echo "Variables (values printed from PHP)\n";
32
33         echo "ivar      = $ivar\n";
34         echo "svar      = $svar\n";
35         echo "lvar      = $lvar\n";
36         echo "uivar     = $uivar\n";
37         echo "usvar     = $usvar\n";
38         echo "ulvar     = $ulvar\n";
39         echo "scvar     = $scvar\n";
40         echo "ucvar     = $ucvar\n";
41         echo "cvar      = $cvar\n";
42         echo "fvar      = $fvar\n";
43         echo "dvar      = $dvar\n";
44         echo "strvar    = $strvar\n";
45         echo "cstrvar   = $cstrvar\n";
46         echo "iptrvar   = $iptrvar\n";
47         echo "name      = $name\n";
48         echo "ptptr     = $ptptr" , point_print($ptptr) , "\n";
49         echo "pt        = $pt" , point_print($pt) , "\n";
50
51         echo "\nVariables (values printed from C)\n";
52
53         print_vars();
54
55         echo "\nI'm going to try and update a structure variable.\n";
56
57         $pt = $ptptr;
58
59         echo "The new value is \n";
60
61         pt_print();
62
63         echo "You should see the value", point_print($ptptr), "\n";
64
65         echo "\nNow I'm going to try and modify some read only variables\n";
66
67         echo "Trying to set 'path'\n";
68
69         /* Sadly this works */
70         $path = "Whoa!";
71         echo "Path = $path\n";
72
73         echo "Trying to set 'status'\n";
74
75         /* And this */
76         $status = 0;
77         echo "Status = $status\n";
78
79 ?>
80