- Abstract class’s abstract function cannot be declared private. It can be protected or public (default).
- Abstract class’s non abstract method can be private.
- To declare abstract keyword is abstract.
- Any class’s public method can also be called like this Car::carSpeed(); , if there is no __construct declared or it is there but don’t need any arguments to initiate the class.
- Narrowing is not allowed only widening is allowed in inheritance concept weather you are working with abstract class interface or just simple inheritance.(Narrowing:-decreasing access level like in parent it was public and in child you are changing it to the protected or private. Widening: – increasing the access level like in parent it is private and you are changing it to public or protected.)
- Static method cannot be private it can be protected or public.
- Interface can have static method but in that case it also should be declared static in implementing class.
- Every method of interface must be public there is no other option.
- Interface cannot contain any member variables, not even static, only functions are allowed.
- Abstract class can contain any type of member variables (private, public, protected or static ).
- When writing public static then keyword order doesn’t matter , you can write like this also static public.
- When writing static method private or protected it will not give any error it can be. But the condition is you are using it in child class .if you will use it like this Car::carSpeed(); then it will show error.
High Level PHP Oop Concept
What Is Zend Engine
Zend Engine is an open source scripting engine just like engine in a car. The Zend Engine is developed by two students Zeev Suraski and Andi Gutmans (at the Technion – Israel Institute of Technology) in 1999 for PHP4 called Zend Engine-1, and the current is for PHP5 called as Zend Engine-2. Before these engines we were using old and less powerful engine developed by the inventor of PHP Rasmus Lerdorf.
Here is the brief of zend engine, it consists of fallowing:
- Interpreter(Run Time Compiler)
- Executor
- Function Module Interface
I am expecting that we all know what is interpreter so there is no need to discuss it. The latest feature is Extension Interface that makes it extensible, like Zend Debugger,Zend Optimizer,Zend Persistent compiled Script Registry and Zend script to binary file compiler, this feature is not depicted in diagram. Executor is responsible for finally executing the code and generating output. Function module interface is used for including different functionality like MySql,Oracle,PostgreeSQL,XML,Math,Com Components, ODBC, WDDX etc. So the conclusion is Zend Engine is just a virtual machine that is responsible for including different modules to finally providing the output, the interpreter is just a small part of it.
Stop PHP errors by using .htaccess file
Just paste the given below file in a .htaccess file and put it in a web directory(generally root) and see the magic, dont forget to provide a log file at the end if you want to store all errors.
php_value error_reporting 2047
php_flag display_errors false
php_flag display_startup_errors false
php_flag log_errors true
php_value log_errors_max_len 100M
php_flag html_errors false
php_value log.txt ../log
PHP 5 Paging Class
I have written a class and a example below the class to help you to use.
<?php
class paging
{
public $mysqli=NULL;
public $result=NULL;
public $totalrows=NULL;
public $currentpage=1;
public $limit=4;
function __construct()
{
$this->mysqli= new mysqli (‘localhost’,'root’,”,’test’);
}
public function myresullt ($query)
{
$this->totalrows=$this->mysqli->query($query)->num_rows;
$new_query=$query.’ limit ‘. (($this->currentpage*$this->limit)-$this->limit).’,’.$this->limit;
$this->result=$this->mysqli->query($new_query);
}
public function myfetch ()
{
return $this->result->fetch_array(MYSQLI_NUM);
}
public function createpaging ()
{
$totalpage=(int)($this->totalrows / $this->limit);
if($this->totalrows % $this->limit)
{
$totalpage+=1;
}
for($i=1;$i<=$totalpage;$i++)
{
echo ‘<a href=’.$_SERVER['SCRIPT_NAME'].’?page=’.$i.’>’.$i.’</a> ‘;
}
}
}
$mypaging=new paging();
if(isset($_GET['page']))
{
$mypaging->currentpage=$_GET['page'];
}
?>
<table border=”1″>
<tr>
<th>User ID</th>
<th>Name</th>
<th>Address</th>
</tr>
<?php
$mypaging->myresullt(“select * from employee”);
while($row=$mypaging->myfetch())
{
echo’<tr>’;
echo ‘<td>’.$row[0].’</td>’;
echo ‘<td>’.$row[1].’</td>’;
echo ‘<td>’.$row[2].’</td>’;
echo’</tr>’;
}
?>
<tr>
<td colspan=”3″ align=”center”><?php echo $mypaging->createpaging(); ?></td>
</tr>
</table>
