Learn PHP
PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages.
PHP is a widely-used, free, and efficient alternative to competitors such as Microsoft's ASP.
Start learning PHP now »
Easy Learning with "PHP Tryit"
With our online "PHP Tryit" editor, you can edit the PHP code, and click on a button to view the result.
Example
Try it Yourself »
Click on the "Try it Yourself" button to see how it works.
PHP Exercises
PHP Examples
Learn by examples! This tutorial supplements all explanations with clarifying examples.
See All PHP Examples
PHP Quiz Test
Learn by taking a quiz! This quiz will give you a signal of how much you know, or do not know, about PHP.
Start PHP Quiz!
My Learning
Track your progress with the free "My Learning" program here at W3Schools.
Log into your account, and start earning points!
This is an optional feature, you can study W3Schools without using My Learning.
PHP References
W3Schools' PHP reference contains different categories of all PHP functions, keywords and constants, along with examples.
Kickstart your career
Get certified by completing the course
Get certified
PHP मे Function का उपयोग Code के Reduplication को कम करने के लिए किया जाता है. Function के उपयोग से Code की Clarity मे सुधार किया जाता है Function सरल Pieces मे Complex Problems को भी कम कर देता है.
Nội dung chính
- Functions With Parameters
- For Example
- Passing Arguments by Reference
- For Example
- Dynamic Function
- For Example
- Function Returning Value
- For Example
- PHP Function Syntax
- PHP Function Example
- PHP Function : Important Tips
- PHP Function Advantages
- PHP Types Of Function
Function Statement का एक Section होता है जिसका उपयोग किसी कार्यक्रम में बार-बार किया जा सकता है. यह Page के Load होने पर तत्काल Execute नहीं होता है इसे Function पर Call करके Execute किया जाता है.
Function Code का एक Piece है जो Parameter के रूप में Input लेता है और Processing के बाद एक Value Return देता है. PHP मे Function अन्य Programming Language के कार्यों के समान होती है. इसको Declare करने के लिए Function Keywords की आवश्यकता होती है.
Function को Body मे Define या Execute किया जाता है जो Curly Bracket के बीच मे होता है.
PHP Language में हजारों built-in Functions हैं.
Functions With Parameters
PHP आपको एक functions के अंदर अपने Parameters को पास करने का विकल्प देता है जिससे आप ज्यादा Parameters को पास कर सकते है.
For Example
Function with Parameters Example
Output
Total of the two numbers is : 95
Passing Arguments by Reference
Functions को Reference द्वारा Arguments भेजना संभव है. इसका मतलब है कि Variable के Reference में Functions के द्वारा Variable की Value को कापी के बजाय हेरफेर किया जाता है.
For Example
Passing Arguments by Reference Example
Output
Original Value is 30
Changed Original Value is 25
Dynamic Function
Function के नाम को Variables के रूप में Assign करना मुमकिन है और फिर इन Variables को उसी तरह से व्यवहार करना चाहिए जैसा आप Function नाम ही करेंगे.
For Example
Dynamic Function Example
Output
You are calling printText function dynamically.
Function Returning Value
एक Function Value या Object के साथ संयोजन के साथ Return Statement का उपयोग करके एक Value को वापस कर सकता है. Return Function के निष्पादन को बंद कर देता है और Value वापस कॉलिंग कोड को भेजता है.
For Example
Function Returning Value Example
Output
Total of the two numbers is : 77
PHP Articles in Hindi
Function reusable piece of code या block of code होता है जो कि कोई specific task perform करता है। एक बार define करने के बाद हम इन्हें कितनी ही बार use कर सकते हैं। PHP में 1000+ predefined useful function हैं जिन्हें हम Built In Functions कहते हैं।
हालाँकि PHP हमें ये facility provide करती है कि user खुद के function define कर सके जिनहे User Defines Functions कहते हैं । Web page load होते समय कोई भी function automatically run नहीं होता है जब तक कि हम उसे call न करें।
PHP Function Syntax
function function_name[] { //perform task here return something /*it's optional*/ }
Function में return statement optional होता है , आप चाहे तो कोई value या statement return करा सकते हैं।
PHP Function Example
File : function.php