Php Keywords Best Tutorial In Hindi

Php Keywords : Php में कुछ Predefined Words होते हैं जिन्हे हम Keywords कहते हैं, इन Keywords का काम पहले से ही Define होता हैं

हम इन Keywords के नाम के variables , constant variables, namespaces , class names , traits etc. नहीं बना सकते है , क्योकि अगर हम ऐसा करेंगे तो हमारे द्वारा बनाये गए Variable और Actual Keyword में Confusion Create हो जाएगी और Program में Errors आएँगी।

For ex.

<?php 
  class First
   {
  	function __construct()
  	{
  		echo 'Hello Constructor';
  	}
   } 
 // make new object of the class
 new First(); 
?> 
PHP
Php Keyword in hindi by crackexam

जैसा की आप देख रहें मैंने echo-and-print.php नाम की एक file बनायीं जिसमे मैंने ECHO नाम की class बनाकर उसका Object बनाने की कोशिश की जिससे Constructor में value को print किया जा सके।

हालाँकि हम जानते है की ECHO हम किसी variable को print करने के लिए use करते हैं, इसलिए हमें Error प्राप्त हुई।

इसलिए जब हम किसी project पर काम   करे तो हमें यह बात ध्यान में रखनी चाहिए की  variables , constant variables, namespaces , class names , traits etc. के नाम meaningful  होने चाहिए , और जो PHP के predefined keywords के साथ match न करें ,  जिससे हमारे Code  को समझने और Error Handling में आसानी हो सके।

List Of PHP Keywords

KeywordDescription
abstractDeclare a class as abstract
andA logical operator
asUsed in the foreach loop
breakBreak out of loops and switch statements
callableA data type which can be executed as a function
caseUsed in the switch conditional
catchUsed in the try..catch statement
classDeclare a class
cloneCreate a copy of an object
constDefine a class constant
continueJump to the next iteration of a loop
declareSet directives for a block of code
defaultUsed in the switch statement
doCreate a do…while loop<
echoOutput text
elseUsed in conditional statements
elseifUsed in conditional statements
emptyCheck if an expression is empty
enddeclareEnd a declare block
endforEnd a for block
endforeachEnd a foreach block
endifEnd an if or elseif block
endswitchEnd a switch block
endwhileEnd a while block
extendsExtends a class or interface
finalDeclare a class, property or method as final
finallyUsed in the try…catch statement
fnDeclare an arrow function
forCreate a for loop
foreachCreate a foreach loop
functionCreate a function
globalImport variables from the global scope
gotoJump to a line of code
ifCreate a conditional statement
implementsImplement an interface
includeEmbed code from another file
include_onceEmbed code from another file
instanceofTest an object’s class
insteadofResolve conflicts with traits
interfaceDeclare an interface
issetCheck if a variable exists and is not null
listAssigns array elements into variables
namespaceDeclares a namespace
newCreates an object
orA logical operator
printOutput text
privateDeclare a property, method or constant as private
protectedDeclare a property, method or constant as protected
publicDeclare a property, method or constant as public
requireEmbed code from another file
require_onceEmbed code from another file
returnExit a function and return a value
staticDeclare a property or method as static
switchCreate a switch block
throwThrow an exception
traitDeclare a trait
tryCreate a try…catch structure
unsetDelete a variable or array element
useUse a namespace
varDeclare a variable
whileCreate a while loop or end a do…while loop
xorA logical operator
yieldUsed in generator functions
yield fromUsed in generator functions
error: Content is protected!! You are not allowed to copy.