{"id":799,"date":"2015-12-10T07:33:02","date_gmt":"2015-12-10T11:33:02","guid":{"rendered":"https:\/\/www.searchenginegenie.com\/programming-blog\/?p=799"},"modified":"2015-12-10T07:38:05","modified_gmt":"2015-12-10T11:38:05","slug":"php-functions","status":"publish","type":"post","link":"https:\/\/www.searchenginegenie.com\/programming-blog\/php-functions\/","title":{"rendered":"PHP Functions"},"content":{"rendered":"<p style=\"text-align: justify;\">A PHP function is a block of statements that can be used repeatedly in a program. It is not executed when page is loaded, instead implemented when a function is called.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"font-weight:bold\">Function Syntax<\/p>\n<p>Function function _name ()<br \/>\n{<br \/>\nCode to be executed;<br \/>\n}<br \/>\n&nbsp;<\/p>\n<p style=\"font-weight:bold\">Example<\/p>\n<p>Function test()<br \/>\n{<br \/>\nEcho \u201chello\u201d;<br \/>\n}<br \/>\nTest();<br \/>\n&nbsp;<\/p>\n<p style=\"font-weight:bold\">Function with arguments<\/p>\n<p style=\"text-align: justify;\">Arguments or parameters are a piece of information, which is passed to function for executing the code. Functions can have any number of arguments, just separate them by comma.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\">Function test($fname)<br \/>\n{<br \/>\nEcho $fname;<br \/>\n}<br \/>\nTest(\u201cjanani\u201d);<\/p>\n<p>&nbsp;<\/p>\n<p style=\"font-weight:bold\">Default Argument Value<\/p>\n<p style=\"text-align: justify;\">The default argument will be set, if a function is called without parameters.<\/p>\n<p>&nbsp;<br \/>\nFunction test($fname=50)<br \/>\n{<br \/>\nEcho $fname;<br \/>\n}<br \/>\nTest();<br \/>\n&nbsp;<\/p>\n<p style=\"font-weight:bold\">Return value function<\/p>\n<p style=\"text-align: justify;\">Return value function is used when a function has to return a value after code execution.<\/p>\n<p>&nbsp;<br \/>\nFunction test ($a, $b)<br \/>\n{<br \/>\nReturn $a+$b;<br \/>\n}<br \/>\nEcho Test(2,3);<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A PHP function is a block of statements that can be used repeatedly in a program. It is not executed when page is loaded, instead implemented when a function is called. &nbsp; Function Syntax Function function _name () { Code to be executed; } &nbsp; Example Function test() { Echo \u201chello\u201d; } Test(); &nbsp; Function [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13,1],"tags":[],"class_list":["post-799","post","type-post","status-publish","format-standard","hentry","category-php","category-programming"],"_links":{"self":[{"href":"https:\/\/www.searchenginegenie.com\/programming-blog\/wp-json\/wp\/v2\/posts\/799","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.searchenginegenie.com\/programming-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.searchenginegenie.com\/programming-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.searchenginegenie.com\/programming-blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.searchenginegenie.com\/programming-blog\/wp-json\/wp\/v2\/comments?post=799"}],"version-history":[{"count":6,"href":"https:\/\/www.searchenginegenie.com\/programming-blog\/wp-json\/wp\/v2\/posts\/799\/revisions"}],"predecessor-version":[{"id":806,"href":"https:\/\/www.searchenginegenie.com\/programming-blog\/wp-json\/wp\/v2\/posts\/799\/revisions\/806"}],"wp:attachment":[{"href":"https:\/\/www.searchenginegenie.com\/programming-blog\/wp-json\/wp\/v2\/media?parent=799"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.searchenginegenie.com\/programming-blog\/wp-json\/wp\/v2\/categories?post=799"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.searchenginegenie.com\/programming-blog\/wp-json\/wp\/v2\/tags?post=799"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}