In the following code, which class can be instantiated?
In the following code, which class can be instantiated?
<code>
1 <?php
2 abstract class Graphics {
3 abstract function draw($im, $col);
4 }
5
6 abstract class Point1 extends Graphics {
7 public $x, $y;
8 function __construct($x, $y) {
9 $this->x = $x;
10 $this->y = $y;
11 }
12 function draw($im, $col) {
13 ImageSetPixel($im, $this->x, $this->y, $col);
14 }
15 }
16
17 class Point2 extends Point1 { }
18
19 abstract class Point3 extends Point2 { }
20 ?>
</code>
Would the following code catch a parse error?
Would the following code catch a parse error?
<code>
try {
echo $label
} catch (Exception $e) {
echo $e->getMessage();
}
</code>
What is the error in the following declaration of a static class method?
What is the error in the following declaration of a static class method?
<code>
1 <?php
2 class car {
3 static $speeds = array(
4 ‘fast’,
5 ‘slow’,
6 ‘medium’,
7 );
8
9 static function getSpeeds()
10 {
11 return $this->speeds;
12 }
13 }
14 ?>
</code>
The purpose of the singleton pattern is to…
The purpose of the singleton pattern is to…
Is the following code piece E_STRICT compliant?
Is the following code piece E_STRICT compliant?
<code>
final class Testing {
private $test;
public function tester() {
return “Tested!”;
}}
</code>
Which of the following code snippets is correct?
Which of the following code snippets is correct? (Choose 2)
a)
interface Drawable {
abstract function draw();
}
b)
interface Point {
function getX();
function getY();
}
c)
interface Line extends Point {
function getX2();
function getY2();
}
d)
interface Circle implements Point {
function getRadius();
}
Which PHP configuration directive can be disabled to prevent this?
One common security risk is exposing error messages directly in the browser. Which PHP
configuration directive can be disabled to prevent this?
How would you correct it?
The following code piece should print “PHP is cool”, but unexpectedly, it just prints “cool”. How
would you correct it?
<code>
echo str_replace(‘PHP is a pain.’, ‘a pain’, ‘cool’);
</code>
What happens if you try to access a property whose name is defined in a parent class as private, and is not de
What happens if you try to access a property whose name is defined in a parent class as private,
and is not declared in the current class?
What is the output of the following code?
What is the output of the following code?
<code>
$first = “second”;
$second = “first”;
echo $$$first;
</code>