-
Notifications
You must be signed in to change notification settings - Fork 1
/
Test.php
72 lines (57 loc) · 1.36 KB
/
Test.php
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
<?php
/**
* How do you declare a function or method that you want to be accessed without instantiate the class?
* - By defining function static
*/
Class AccessSpecifiers {
public static function testStatic() {
return false;
}
}
/**
* How do you create a child class of BaseClass ?
* - Through inheritence using keyword extends
*/
Class MyParent {}
Class Son extends MyParent {}
/**
* Please write a conditional block of code that
* check if the variable $var exists, is not null
* and it's a number.
*/
Class TestVar {
public static $var;
public static function checkVar($var) {
self::$var = $var;
if (property_exists(__CLASS__,'var') &&
!is_null(self::$var) &&
is_int(self::$var)) {
echo self::$var;
} else {
echo 'undefined var';
}
}
}
//TestVar::checkVar(10);
/**
* Write a function that adds a line to a log file
* the current date and time with this format:
* "[2013-09-23 00:30:15] - Status OK"
*/
Class LogString {
private $__var;
public function __construct() {
error_log("[".date("Y-m-d H:i:s")."] - Status OK", 3, "error.log");
}
}
$obj = new LogString();
/**
* Which is the default path where you set up the
* configuration for the database?
* /project/app/Config/database.php
*/
/**
* How you can get the value of a session variable
* with key "foo" using CakePHP ?
* $this->Session->read('foo');
*/