PHP video tutorial 36 – PHP Special Operators in PHP
( new , instanceof, member access & scope resolution operators)
PHP Special Operators
new operator:
– is used to create new instance of a class
Syntax:
$variableName = new ClassName();
instanceof operator:
– is used to test whether a variable is pointing to an instance of a specific class
Syntax:
$variableName instanceof ClassName
member access operator (->):
– is used to access members of an object
Syntax:
$variableName->memberName
scope resolution operator(::):
– is used to access static, constant & overridden members of a class
Syntax:
$variableName::memberName
OR
ClassName::memberName
Example Code:
class Circle
{
var $radius = 10;
const PI=3.142;
}
$circle1 = new Circle();
echo $circle1 instanceof Circle ? “true” : “false”; // true
echo “<br/>”;
echo $circle1->radius; // 10
echo “<br/>”;
echo Circle::PI; // or $circle1::PI; // 3.142
echo “<br/>”;
=========================================
Follow the link for next video:
PHP video tutorial 37 – Precedence & Associativity of operators in PHP
Follow the link for previous video:
PHP video tutorial 35 – PHP String Operators in PHP
=========================================
Nguồn: https://svdpch.org/
Xem thêm bài viết khác: https://svdpch.org/cong-nghe/
SUBSCRIBE, SHARE & SUPPORT:
https://www.youtube.com/chidrestechtutorials
VISIT & LEARN AT FREE OF COST:
https://www.chidrestechtutorials.com