summaryrefslogtreecommitdiff
path: root/Examples/php4/variables/runme.php4.old
blob: 9a6bfb3862dc6cd4f0cbd33a6dd73555d483f5ed (plain)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
### THIS VERSION was written for when php global vars fakingly mirrored
### the wrapped global vars, but it was very inefficient.
### For now we don't do this (pending some changes to php itself) so
### we use accessor functions instead; WE KEEP THIS version around ready
### for when those php changes are made and we can switch back.
### Specifically we want $_GLOBALS variable overloading like object 
### property overloading

	require "example.php";

	/* Try to set the values of some global variables */

	$ivar = 42;
	$svar = -31000;
	$lvar = 65537;
	$uivar = 123456;
	$usvar = 61000;
	$ulvar = 654321;
	$scvar = -13;
	$ucvar = 251;
	$cvar = "S";
	$fvar = 3.14159;
	$dvar = 2.1828;
	$strvar = "Hello World";
	$cstrvar = "Goodbye";
	$iptrvar = new_int(37);
	$ptptr = new_point(37,42);
	$name = "Bill";

	echo "Variables (values printed from PHP)\n";

	echo "ivar	= $ivar\n";
	echo "svar	= $svar\n";
	echo "lvar	= $lvar\n";
	echo "uivar	= $uivar\n";
	echo "usvar	= $usvar\n";
	echo "ulvar	= $ulvar\n";
	echo "scvar	= $scvar\n";
	echo "ucvar	= $ucvar\n";
	echo "cvar	= $cvar\n";
	echo "fvar	= $fvar\n";
	echo "dvar	= $dvar\n";
	echo "strvar	= $strvar\n";
	echo "cstrvar	= $cstrvar\n";
	echo "iptrvar	= $iptrvar\n";
	echo "name	= $name\n";
	echo "ptptr	= $ptptr" , point_print($ptptr) , "\n";
	echo "pt	= $pt" , point_print($pt) , "\n";

	echo "\nVariables (values printed from C)\n";

	print_vars();

	echo "\nI'm going to try and update a structure variable.\n";

	$pt = $ptptr;

	echo "The new value is \n";

	pt_print();

	echo "You should see the value", point_print($ptptr), "\n";

	echo "\nNow I'm going to try and modify some read only variables\n";

	echo "Trying to set 'path'\n";

	/* Sadly this works */
	$path = "Whoa!";
	echo "Path = $path\n";

	echo "Trying to set 'status'\n";

	/* And this */
	$status = 0;
	echo "Status = $status\n";

?>