{"id":10146,"date":"2020-02-11T12:19:25","date_gmt":"2020-02-11T12:19:25","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=10146"},"modified":"2022-05-08T12:07:20","modified_gmt":"2022-05-08T12:07:20","slug":"how-to-define-call-create-a-function-in-php","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/how-to-define-call-create-a-function-in-php\/","title":{"rendered":"How to Define, Call &#038; Create a function in PHP?"},"content":{"rendered":"\n<p><strong>What is function in PHP?<\/strong><br> PHP provides us many built-in helper partners works that you can call anyplace inside your application OR browser. They make your work process advantageous for working with exhibits and articles, ways, strings, URLs and different sorts.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"542\" height=\"412\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/02\/function-in-php.jpg\" alt=\"\" class=\"wp-image-10148\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/02\/function-in-php.jpg 542w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/02\/function-in-php-300x228.jpg 300w\" sizes=\"auto, (max-width: 542px) 100vw, 542px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"528\" height=\"226\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/02\/create-function.png\" alt=\"\" class=\"wp-image-10147\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/02\/create-function.png 528w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/02\/create-function-300x128.png 300w\" sizes=\"auto, (max-width: 528px) 100vw, 528px\" \/><\/figure>\n\n\n\n<p>ex:-<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/ajcotocus\/6c82e769507a09bb0effaed6fee4b3c5.js\"><\/script>\n\n\n\n<p><strong>Why use Function in PHP:-<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>You can use Easy to Debug.<\/li><li>It is Reusability<\/li><li>It is no code repetition<\/li><li>Easy to handle codes<\/li><\/ul>\n\n\n\n<p><strong>Rules for PHP variables:-<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Function name starts only with a letter or underscore(_).<\/li><li>Function name cannot start with a number if the start then shows an error.<\/li><li>You can not use reserved keywords as :- else, if, for, each, etc.<\/li><li>Function names are case-insensitive, thus it is usually good form to call functions it appear in their declaration.<\/li><\/ul>\n\n\n<div class=\"epyt-gallery\" data-currpage=\"1\" id=\"epyt_gallery_86057\"><figure class=\"wp-block-embed wp-block-embed-youtube is-type-video is-provider-youtube epyt-figure\"><div class=\"wp-block-embed__wrapper\"><iframe loading=\"lazy\"  id=\"_ytid_27297\"  width=\"760\" height=\"427\"  data-origwidth=\"760\" data-origheight=\"427\" src=\"https:\/\/www.youtube.com\/embed\/?enablejsapi=1&#038;autoplay=0&#038;cc_load_policy=0&#038;cc_lang_pref=&#038;iv_load_policy=1&#038;loop=0&#038;rel=1&#038;fs=1&#038;playsinline=0&#038;autohide=2&#038;theme=dark&#038;color=red&#038;controls=1&#038;disablekb=0&#038;\" class=\"__youtube_prefs__  no-lazyload\" title=\"YouTube player\"  data-epytgalleryid=\"epyt_gallery_86057\"  allow=\"fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen data-no-lazy=\"1\" data-skipgform_ajax_framebjll=\"\"><\/iframe><\/div><\/figure><div class=\"epyt-gallery-list\"><div>Sorry, there was a YouTube error.<\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>What is function in PHP? PHP provides us many built-in helper partners works that you can call anyplace inside your application OR browser. They make your work process advantageous for working with exhibits and articles, ways, strings, URLs and different sorts. ex:- Why use Function in PHP:- You can use Easy to Debug. It is&#8230;<\/p>\n","protected":false},"author":1,"featured_media":10149,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","_joinchat":[],"footnotes":""},"categories":[5150],"tags":[3051,350,5892,5431,177],"class_list":["post-10146","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php","tag-call","tag-create","tag-define","tag-function","tag-php"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/10146","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=10146"}],"version-history":[{"count":2,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/10146\/revisions"}],"predecessor-version":[{"id":24965,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/10146\/revisions\/24965"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media\/10149"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=10146"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=10146"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=10146"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}