PHP Keywords In Hindi


PHP keywords , PHP में predefined कुछ words होते जिनका कुछ मतलब होता है। और इन words / keywords के नाम के variables , constant variables, namespaces , class names , traits etc. हम नहीं बना सकते है , क्योंकि इससे हमरे द्वारा बनाए गए variables और actual keywords में confusion होती है , इसलिए हम इन्हे define नहीं कर सकते हैं। और अगर हम ऐसा करते भी है तो error आएगी।

For Example :

<?php class ECHO { function __construct() { echo 'Hello Constructor'; } } // make new object of the class new ECHO(); ?>

Output :

 Parse error: syntax error, unexpected 'ECHO' (T_ECHO), expecting identifier (T_STRING) in C:\xampp\htdocs\test\test.php on line 2

जैसा की आप देख रहें मैंने test.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 में आसानी हो सके।

PHP Keywords

PHP में keywords नीचे define किये गए हैं।

Keyword NameUses
abstractTo define abstract class
echo / echo() / ECHO / ECHOTo print value assigned in a variable
print / print() / PRINT / PRINT To print formatted value assigned in a variable
array()To define array
andUses as a Logical operators
asWorks with foreach loop
breakTo break structure of the given loop (For loop or While loop)
caseWorks with Switch
catchHandles Errors
classDefines a class
cloneMakes clone object of a object
constDefine constant variable in a class
continue To skip the structure at a specified condition in a loop (for loop or while loop)
dieExit the script execution and equivalent to exit
exitExit the script execution and equivalent to die
doWorks with While loop . Execute the script then check condition .
ifExecutes if given condition is true.
elseWorks with if statement , execute if condition is not satisfied.
else ifWorks with if statement , execute if upper condition is not satisfied.
emptyChecks if a variable has a value or not.
endifTells where if-else loop getting end.
foreachTo iterate the array variable.
endforeachTells where foreach loop getting end.
forIterate the loop of given
endswitchTells where switch loop getting end.
endwhileTells where while loop getting end.
extendsTo inherit a class
finalDefine a final method. Which prevents child classes from overriding that method.
finallyWorks with Try block . Finally block runs every time .
functionTo define a function .
globalTo define a global variable.
gotogoto operator can be used to jump to another section in the program.
implemetsTells that a class implementing a interface
includeInclude a another file in current file.
include_onceIncludes a file only once
interfaceTo define a interface
instanceofDetermines whether a PHP variable is an instantiated object of a certain class.
isset()Checks whether a variable defiened or not.
namespaceTo Define a namespace .
newUses to cerate a object of a class.
orLogical Operator.
privateTo define a private variables or functions in a class.
protectedTo define a protected variables or functions in a class.
publicTo define a public variables or functions in a class.
requireIncludes a file , also produce the fatal error if file not exists.
require_onceIncludes a file only once , also produce the fatal error if file not exists.
staticTo define static properties in a class.
switchTo define /start switch loop.
traitTo define a trait .
tryHandels the exception
unset()Unset a given variable
varTo define a variable with public visibility in a class.
whileTo Define / start while loop.
__LINE__Current line number
__FILE__Returns the full file path with file name.
__DIR__Returns the directory of the.
__FUNCTION__Returns the function name or {closure} for anonymous functions.
__CLASS__Returns the class name.
__TRAIT__Returns the trait name that may include namespace.
__METHOD__Returns the method name .
__NAMESPACE__Returns the namespace name

I Hope अब आप keywords को अच्छी तरह से समझ गए होंगे। इसके अलावा PHP हमें कुछ Magic Constants भी provide करतीं है जिनका result उनके use किये गए स्थान के accordingly change होता रहता है।

Hey ! I'm Rahul founder of learnhindituts.com. Working in IT industry more than 4.5 years. I love to talk about programming as well as writing technical tutorials and blogs that can help to others .... keep learning :)

Get connected with me - LinkedIn Twitter Instagram Facebook