Thanks sir for great job, I have read many documents to understand oops concept but I was not cleared, and your video did miracle for me with real time example, keep continue share knowledge 🙏
I would like to say that you are really good in teaching. I get a lot of help from this tutorial series. I hope you will continue with more tutorials in future.
Good job Rahul. I will appreciate your way to teaching with real time example. The use of late static binding was not clear for me before watching this video but i came to know the actual use of it in PHP frameworks. Thanks a'lot Rahul....... :)
Thanks for the video, I understood the concept of late static binding, that self keyword always relates to the class where it is mentioned, it is resolved at compile time, and static keyword relates to the class which is inheriting it, and it's resolved at run time: class Abc { public static function myStatic(){ return new static; } public static function mySelf(){ return new self; } } class Def extends Abc {} $def = new Def; echo get_class($def->myStatic()); //returns Def echo get_class($def->mySelf()); //returns Abc --------------------------------------------------------------------- But I have one question, the example you gave, the same result we can achieve without using static property and static keyword, like this: --------------------------------------------------------------------- class DB { protected $table = "defaultTable"; public function getTable(){ return $this->table; } } class Abc extends DB{ //needs default table to be set as table } class Def extends DB{ protected $table = "def"; } class Xyz extends DB{ protected $table = "xyz"; } $db = new DB; $abc = new Abc; $def = new Def; $xyz = new Xyz; echo $db->getTable(); //returns defaultTable echo $abc->getTable(); //returns defaultTable echo $def->getTable(); //returns def echo $xyz->getTable(); //returns xyz -------------------------------------------------------------------- So I just want to know that does it make any difference in this case? --------------------------------------------------------------------
Hi sir, I have Two Questions? 1 ) The same thing can be achieved with simple class and objects like class base{ public $_table='baseTable'; public function get(){ return 'Get Data From '.$this->_table; } } class model extends base{ public $_table = 'Product'; } class newmodel extends base{ public $_table = 'Customer'; } $obj = new model; echo $obj->get().""; $obj = new newmodel; echo $obj->get(); OUTPUT // Get Data From Product Get Data From Customer Then what is the need of using late static binding? 2) Does PHP allocate any memory to class if I don't create any object of that class. (Suppose If I include 50 Classes in file and don't create any objects so is it going to allocate memory? Please Reply...
For LateStatic Binding we use static keyword instead of self , static keyword makes the variable pending at the run time and after run time it checks that from which class the function is being called , and accordingly it picks the value of variable from the class the function has been called. So if the variable table is called from class DB then it will have Value baseTable and if it is called from table abc then it will have the value abc.
This is not a good example. What if you have two classes named Table1 and Table2 and both are extending DB class. Then how will you use the insert method from parent class on two different tabes without defining it again in child class. How ill you change the table name in DB class's insert method?
when class is extended and both parent and child class has static functions, does the static functions doesnt override the base class function when we call the function by creating an object ?
I always come to this PHP tutorials when I prepare for interviews well simply explained concepts.
Usefull video... Good video
it was amazing
Very well exaplined
Rahul you are awesome seriously the way you deliver. Respect from Lahore, Pakistan.
Thanks sir for great job, I have read many documents to understand oops concept but I was not cleared, and your video did miracle for me with real time example, keep continue share knowledge 🙏
Outstanding , if someone to clear their concept then he is in right place
thank's a lot . It made the concept clear regarding why to use late_static_binding
I would like to say that you are really good in teaching. I get a lot of help from this tutorial series. I hope you will continue with more tutorials in future.
Good job Rahul. I will appreciate your way to teaching with real time example. The use of late static binding was not clear for me before watching this video but i came to know the actual use of it in PHP frameworks.
Thanks a'lot Rahul....... :)
best tutorial ever
Amazing tutorial. well done mate. simple way to explain things
very useful. Thank You
Thanks for the video, I understood the concept of late static binding, that self keyword always relates to the class where it is mentioned, it is resolved at compile time, and static keyword relates to the class which is inheriting it, and it's resolved at run time:
class Abc {
public static function myStatic(){ return new static; }
public static function mySelf(){ return new self; }
}
class Def extends Abc {}
$def = new Def;
echo get_class($def->myStatic()); //returns Def
echo get_class($def->mySelf()); //returns Abc
---------------------------------------------------------------------
But I have one question, the example you gave, the same result we can achieve without using static property and static keyword, like this:
---------------------------------------------------------------------
class DB {
protected $table = "defaultTable";
public function getTable(){ return $this->table; }
}
class Abc extends DB{
//needs default table to be set as table
}
class Def extends DB{
protected $table = "def";
}
class Xyz extends DB{
protected $table = "xyz";
}
$db = new DB;
$abc = new Abc;
$def = new Def;
$xyz = new Xyz;
echo $db->getTable(); //returns defaultTable
echo $abc->getTable(); //returns defaultTable
echo $def->getTable(); //returns def
echo $xyz->getTable(); //returns xyz
--------------------------------------------------------------------
So I just want to know that does it make any difference in this case?
--------------------------------------------------------------------
thanks for this video
very nice tutorials sir thanx a lot for this.
Nice Tutorial Thanks
Hi sir,
I have Two Questions?
1 ) The same thing can be achieved with simple class and objects like
class base{
public $_table='baseTable';
public function get(){
return 'Get Data From '.$this->_table;
}
}
class model extends base{
public $_table = 'Product';
}
class newmodel extends base{
public $_table = 'Customer';
}
$obj = new model;
echo $obj->get()."";
$obj = new newmodel;
echo $obj->get();
OUTPUT //
Get Data From Product
Get Data From Customer
Then what is the need of using late static binding?
2) Does PHP allocate any memory to class if I don't create any object of that class. (Suppose If I include 50 Classes in file and don't create any objects so is it going to allocate memory?
Please Reply...
Nice Tutorial. Can you do a tutorial on PHP call backs in OOPs.
+Default Name sure.
Sir self:: ka use kya he?
Or static :: ka bhi mtlb kya hota he?
means "static" will hold the last modified value and not what its called upon.
For LateStatic Binding we use static keyword instead of self , static keyword makes the variable pending at the run time and after run time it checks that from which class the function is being called , and accordingly it picks the value of variable from the class the function has been called. So if the variable table is called from class DB then it will have Value baseTable and if it is called from table abc then it will have the value abc.
same i was thinking
nice one!!! But one question... We can do the same thing without using late static..
for example
This is not a good example. What if you have two classes named Table1 and Table2 and both are extending DB class. Then how will you use the insert method from parent class on two different tabes without defining it again in child class. How ill you change the table name in DB class's insert method?
hi sir great tutorial....wht basic knowledge shd i have bfr learning laravel
+affan Kagzi you should learn the OOPs first ..
please upload late static function example
Why does we use static methods and variables?
Hello Sir,
We can also handle this with simple functions then why we user late static binding?
when class is extended and both parent and child class has static functions, does the static functions doesnt override the base class function when we call the function by creating an object ?
insert query dynamic kesay bana saktay hain bcx har table ki fields different hoti hai plz uski koi video bana kay plz share karay :)
Sound bohat low aata hai
in abc class why does variable $table doesn't override?
php interpreter or compiler?
interpreter
Apka voice kitna kam q sunai de rha hai?