{"id":7645,"date":"2021-08-09T12:19:54","date_gmt":"2021-08-09T12:19:54","guid":{"rendered":"https:\/\/www.scmgalaxy.com\/tutorials\/?p=7645"},"modified":"2021-08-09T12:19:56","modified_gmt":"2021-08-09T12:19:56","slug":"complete-tutorial-for-function-in-php","status":"publish","type":"post","link":"https:\/\/www.scmgalaxy.com\/tutorials\/complete-tutorial-for-function-in-php\/","title":{"rendered":"Complete tutorial for Function in PHP"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">What is Function?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Function are those callable section of code that you can pass data to, and that can return data to you. Function are subprograms which are used to compute a value or perform a task.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/i.ytimg.com\/vi\/HvxQww-7NGA\/maxresdefault.jpg\" alt=\"PHP Functions Tutorial - Learn PHP Programming - YouTube\"\/><\/figure><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Which are the Importance of Function?<\/h3>\n\n\n\n<ul class=\"wp-block-list\"><li>Easy to debug<\/li><li>Reusability<\/li><li>No code repetition<\/li><li>Easy to handle codes<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">How to create a Function?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Syntax:-<\/strong> <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><span class=\"has-inline-color has-vivid-red-color\">function function_name( )\r\n{\r\n\rBlock of statement;\r\n\r}<\/span><\/code><\/pre>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/02\/function-in-php.jpg\" alt=\"How to Define, Call &amp; Create a function in PHP? - DevOpsSchool.com\"\/><\/figure><\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example:-<\/strong> <\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/AdarshAshwani\/a0e5e2fc75382936ba5db6cd7ee7903b.js\"><\/script>\n\n\n\n<h4 class=\"wp-block-heading\">Some rules for creating a function:-<\/h4>\n\n\n\n<ul class=\"wp-block-list\"><li>Function name only starts with a letter, an underscore ( _ ).<\/li><li>Function name cannot start with a number.<\/li><li>Do not use Predefined constant name e.g. PHP_VERSION ,PHP_OS etc.<\/li><li>Do not use reserved keywords. e.g. else, if etc.<\/li><li>Function names are case-insensitive, though it is usually good form to call functions as they appear in their declaration.<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">How Function Calls in code<\/h3>\n\n\n\n<script src=\"https:\/\/gist.github.com\/AdarshAshwani\/78d01e05dd28eb54975a33efd58f019e.js\"><\/script>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>What is Function? Function are those callable section of code that you can pass data to, and that can return [&hellip;]<\/p>\n","protected":false},"author":33,"featured_media":7005,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[5388],"tags":[6132,6140,6130,6142,6131,545,6141,6139,6138,177,6143,6133,670,6134,6136,6137],"class_list":["post-7645","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php","tag-complete-tutorial-for-function-in-php","tag-create-a-function","tag-function","tag-function-calls-in-code","tag-function-in-php","tag-how","tag-how-function-calls-in-code","tag-how-to-create-a-function","tag-importance-of-function","tag-php","tag-rules-for-creating-a-function","tag-tutorial-for-function-in-php","tag-what","tag-what-is-function","tag-which","tag-which-are-the-importance-of-function"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Complete tutorial for Function in PHP - scmGalaxy<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.scmgalaxy.com\/tutorials\/complete-tutorial-for-function-in-php\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Complete tutorial for Function in PHP - scmGalaxy\" \/>\n<meta property=\"og:description\" content=\"What is Function? Function are those callable section of code that you can pass data to, and that can return [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.scmgalaxy.com\/tutorials\/complete-tutorial-for-function-in-php\/\" \/>\n<meta property=\"og:site_name\" content=\"scmGalaxy\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/profile.php?id=100003935402658\" \/>\n<meta property=\"article:published_time\" content=\"2021-08-09T12:19:54+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-08-09T12:19:56+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/07\/Tutorials-for-PHP-Functions-1.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"600\" \/>\n\t<meta property=\"og:image:height\" content=\"300\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Ashwani Kumar\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ashwani Kumar\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/complete-tutorial-for-function-in-php\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/complete-tutorial-for-function-in-php\\\/\"},\"author\":{\"name\":\"Ashwani Kumar\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/19f28f8f969c1679bfb37d4dad6adc31\"},\"headline\":\"Complete tutorial for Function in PHP\",\"datePublished\":\"2021-08-09T12:19:54+00:00\",\"dateModified\":\"2021-08-09T12:19:56+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/complete-tutorial-for-function-in-php\\\/\"},\"wordCount\":139,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/complete-tutorial-for-function-in-php\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/wp-content\\\/uploads\\\/2021\\\/07\\\/Tutorials-for-PHP-Functions-1.jpg\",\"keywords\":[\"Complete tutorial for Function in PHP\",\"create a Function\",\"Function\",\"Function Calls in code\",\"Function in PHP\",\"How\",\"How Function Calls in code\",\"How to create a Function\",\"Importance of Function\",\"Php\",\"rules for creating a function\",\"tutorial for Function in PHP\",\"What\",\"What is Function\",\"Which\",\"Which are the Importance of Function\"],\"articleSection\":[\"php\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/complete-tutorial-for-function-in-php\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/complete-tutorial-for-function-in-php\\\/\",\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/complete-tutorial-for-function-in-php\\\/\",\"name\":\"Complete tutorial for Function in PHP - scmGalaxy\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/complete-tutorial-for-function-in-php\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/complete-tutorial-for-function-in-php\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/wp-content\\\/uploads\\\/2021\\\/07\\\/Tutorials-for-PHP-Functions-1.jpg\",\"datePublished\":\"2021-08-09T12:19:54+00:00\",\"dateModified\":\"2021-08-09T12:19:56+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/19f28f8f969c1679bfb37d4dad6adc31\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/complete-tutorial-for-function-in-php\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/complete-tutorial-for-function-in-php\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/complete-tutorial-for-function-in-php\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/wp-content\\\/uploads\\\/2021\\\/07\\\/Tutorials-for-PHP-Functions-1.jpg\",\"contentUrl\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/wp-content\\\/uploads\\\/2021\\\/07\\\/Tutorials-for-PHP-Functions-1.jpg\",\"width\":600,\"height\":300},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/complete-tutorial-for-function-in-php\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Complete tutorial for Function in PHP\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#website\",\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/\",\"name\":\"scmGalaxy\",\"description\":\"A Platform for Software Engineers\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/19f28f8f969c1679bfb37d4dad6adc31\",\"name\":\"Ashwani Kumar\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b0fe597f4b8473400f95ce54bee0bdd62df08a319a198ad229b279aaab4f5410?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b0fe597f4b8473400f95ce54bee0bdd62df08a319a198ad229b279aaab4f5410?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b0fe597f4b8473400f95ce54bee0bdd62df08a319a198ad229b279aaab4f5410?s=96&d=mm&r=g\",\"caption\":\"Ashwani Kumar\"},\"description\":\"There is no end to education. It is not that you read a book, pass an examination, and finish with education. The whole of life, from the moment you are born to the moment you die, is a process of learning.\",\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/profile.php?id=100003935402658\",\"https:\\\/\\\/www.instagram.com\\\/adarshashwani\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/adarsh-ashwani-a75b23130\\\/\"],\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/author\\\/ashwani\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Complete tutorial for Function in PHP - scmGalaxy","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.scmgalaxy.com\/tutorials\/complete-tutorial-for-function-in-php\/","og_locale":"en_US","og_type":"article","og_title":"Complete tutorial for Function in PHP - scmGalaxy","og_description":"What is Function? Function are those callable section of code that you can pass data to, and that can return [&hellip;]","og_url":"https:\/\/www.scmgalaxy.com\/tutorials\/complete-tutorial-for-function-in-php\/","og_site_name":"scmGalaxy","article_author":"https:\/\/www.facebook.com\/profile.php?id=100003935402658","article_published_time":"2021-08-09T12:19:54+00:00","article_modified_time":"2021-08-09T12:19:56+00:00","og_image":[{"width":600,"height":300,"url":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/07\/Tutorials-for-PHP-Functions-1.jpg","type":"image\/jpeg"}],"author":"Ashwani Kumar","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Ashwani Kumar","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/complete-tutorial-for-function-in-php\/#article","isPartOf":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/complete-tutorial-for-function-in-php\/"},"author":{"name":"Ashwani Kumar","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/19f28f8f969c1679bfb37d4dad6adc31"},"headline":"Complete tutorial for Function in PHP","datePublished":"2021-08-09T12:19:54+00:00","dateModified":"2021-08-09T12:19:56+00:00","mainEntityOfPage":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/complete-tutorial-for-function-in-php\/"},"wordCount":139,"commentCount":0,"image":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/complete-tutorial-for-function-in-php\/#primaryimage"},"thumbnailUrl":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/07\/Tutorials-for-PHP-Functions-1.jpg","keywords":["Complete tutorial for Function in PHP","create a Function","Function","Function Calls in code","Function in PHP","How","How Function Calls in code","How to create a Function","Importance of Function","Php","rules for creating a function","tutorial for Function in PHP","What","What is Function","Which","Which are the Importance of Function"],"articleSection":["php"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.scmgalaxy.com\/tutorials\/complete-tutorial-for-function-in-php\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/complete-tutorial-for-function-in-php\/","url":"https:\/\/www.scmgalaxy.com\/tutorials\/complete-tutorial-for-function-in-php\/","name":"Complete tutorial for Function in PHP - scmGalaxy","isPartOf":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/complete-tutorial-for-function-in-php\/#primaryimage"},"image":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/complete-tutorial-for-function-in-php\/#primaryimage"},"thumbnailUrl":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/07\/Tutorials-for-PHP-Functions-1.jpg","datePublished":"2021-08-09T12:19:54+00:00","dateModified":"2021-08-09T12:19:56+00:00","author":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/19f28f8f969c1679bfb37d4dad6adc31"},"breadcrumb":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/complete-tutorial-for-function-in-php\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.scmgalaxy.com\/tutorials\/complete-tutorial-for-function-in-php\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/complete-tutorial-for-function-in-php\/#primaryimage","url":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/07\/Tutorials-for-PHP-Functions-1.jpg","contentUrl":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/07\/Tutorials-for-PHP-Functions-1.jpg","width":600,"height":300},{"@type":"BreadcrumbList","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/complete-tutorial-for-function-in-php\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.scmgalaxy.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"Complete tutorial for Function in PHP"}]},{"@type":"WebSite","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#website","url":"https:\/\/www.scmgalaxy.com\/tutorials\/","name":"scmGalaxy","description":"A Platform for Software Engineers","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.scmgalaxy.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/19f28f8f969c1679bfb37d4dad6adc31","name":"Ashwani Kumar","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/b0fe597f4b8473400f95ce54bee0bdd62df08a319a198ad229b279aaab4f5410?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/b0fe597f4b8473400f95ce54bee0bdd62df08a319a198ad229b279aaab4f5410?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/b0fe597f4b8473400f95ce54bee0bdd62df08a319a198ad229b279aaab4f5410?s=96&d=mm&r=g","caption":"Ashwani Kumar"},"description":"There is no end to education. It is not that you read a book, pass an examination, and finish with education. The whole of life, from the moment you are born to the moment you die, is a process of learning.","sameAs":["https:\/\/www.facebook.com\/profile.php?id=100003935402658","https:\/\/www.instagram.com\/adarshashwani\/","https:\/\/www.linkedin.com\/in\/adarsh-ashwani-a75b23130\/"],"url":"https:\/\/www.scmgalaxy.com\/tutorials\/author\/ashwani\/"}]}},"_links":{"self":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/7645","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/users\/33"}],"replies":[{"embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/comments?post=7645"}],"version-history":[{"count":1,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/7645\/revisions"}],"predecessor-version":[{"id":7646,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/7645\/revisions\/7646"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/media\/7005"}],"wp:attachment":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/media?parent=7645"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/categories?post=7645"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/tags?post=7645"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}