Question: What is the output of the following?<?php
$a = 010;
$b = 0xA;
$c = 2;
print $a + $b + $c;
?>
A
B
C
D
E
20
B
22
C
18
D
$a is an invalid value
E
2
Note: Not available
<?php $a = 010; $b = 0xA; $c = 2; print $a + $b + $c; ?>
<?php $a = 20; function myfunction($b) { $a = 30; global $a, $c; return $c = ($b + $a); } print myfunction(40) + $c; ?>
<?php function myfunction() { ??????? print $string; } myfunction("Hello, World!"); ?>
<?php function &find_variable(&$one, &$two, &$three) { if($one > 10 && $one < 20) return $one; if($two > 10 && $two < 20) return $two; if($three > 10 && $three < 20) return $three; } $one = 2; $two = 20; $three = 15; $var = &find_variable($one, $two, $three); $var++; print "1: $one, 2: $two, 3: $three"; ?>
<?php class myClass { private $a; public function __construct() { $this->a = 10; } public function printValue() { print "The Value is: {$this->a}\n"; } public function changeValue($val, $obj = null) { if(is_null($obj)) { $this->a = $val; } else { $obj->a = $val; } } public function getValue() { return $this->a; } } $obj_one = new myClass(); $obj_two = new myClass(); $obj_one->changeValue(20, $obj_two); $obj_two->changeValue($obj_two->getValue(), $obj_one); $obj_two->printValue(); $obj_one->printValue(); ?>
<?php function duplicate($obj) { $newObj = $obj; return $newObj; } $a = new MyClass(); $a_copy = duplicate($a); $a->setValue(10); $a_copy->setValue(20); ?>