{"id":22173,"date":"2016-05-24T03:01:23","date_gmt":"2016-05-23T17:01:23","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=22173"},"modified":"2016-05-24T13:33:09","modified_gmt":"2016-05-24T03:33:09","slug":"functions-with-or-without-return-primer-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/functions-with-or-without-return-primer-tutorial\/","title":{"rendered":"Functions With or Without Return Primer Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href='http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/php_return_or_not.html' title='Functions With or Without Return Primer Tutorial'><img decoding=\"async\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/return_or_not.jpg\"  \/><\/a><p class=\"wp-caption-text\">Functions With or Without Return Primer Tutorial<\/p><\/div>\n<p>Our mention of the WordPress function <a target=_blank title='WordPress explanation of wp_title function' href='https:\/\/developer.wordpress.org\/reference\/functions\/wp_title\/'>wp_title<\/a>( &#8216;|&#8217;, true, &#8216;right&#8217; ) in <a target=_blank title='Search Engine Optimization Meta Description Primer Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/search-engine-optimization-meta-description-primer-tutorial\/'>Search Engine Optimization Meta Description Primer Tutorial<\/a>, with its dual mode (function) return or no return (for display only) modes of use, reminded us of the &#8220;easy&#8221; ways of PHP as a language.  For &#8230;<\/p>\n<ul>\n<li>PHP not to care about whether a function returns a value or not &#8230; is pretty flexible &#8230; and then to consider &#8230;<\/li>\n<li>PHP not caring about the data type of incoming parameters (or arguments) to functions is truly amazing &#8230; but Javascript is similarly flexible, as can be Python and Perl below<\/li>\n<\/ul>\n<p>We decided to put the first one to the test with other languages, and became amazed that the same type of functional writing as you find in WordPress PHP function <a target=_blank title='WordPress explanation of wp_title function' href='https:\/\/developer.wordpress.org\/reference\/functions\/wp_title\/'>wp_title<\/a> is tolerated in all but Java out of &#8230;<\/p>\n<ul>\n<li>Java<\/li>\n<li>C++<\/li>\n<li>C<\/li>\n<li>PHP<\/li>\n<li>Python<\/li>\n<li>Perl<\/li>\n<li>Javascript<\/li>\n<\/ul>\n<p> &#8230; though C++ and C warned about &#8220;control may reach end of non-void function&#8221; during the <i>gcc<\/i> compilation we made.  Java compiled with the error &#8220;missing return statement&#8221;.<\/p>\n<p>Here is the simple programming source code we wrote to show this &#8230;<\/p>\n<div style='height: 900px;'>Java<br \/>\nErroneous (&#8220;missing return statement&#8221;)<br \/>\n<iframe style='width:100%;background-color: white;' height=400 src='http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/php_return_or_not.java_GETME' title='Erroneous Java becomes as below ....'><\/iframe><br \/>\nOkay, but a compromise to way <a target=_blank title='WordPress explanation of wp_title function' href='https:\/\/developer.wordpress.org\/reference\/functions\/wp_title\/'>wp_title<\/a> works &#8230;<br \/>\n<iframe style='width:100%;background-color: white;' height=400 src='http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/php_return_or_not.java-GETME' title='Java compromise'><\/iframe>\n<\/div>\n<div style='height: 430px;'>C++ (warning: &#8220;control may reach end of non-void function&#8221;)<br \/>\n<iframe style='width:100%;background-color: white;' height=400 src='http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/php_return_or_not.cpp-GETME' title='C++'><\/iframe>\n<\/div>\n<div style='height: 400px;'>C  (warning: &#8220;control may reach end of non-void function&#8221;)<br \/>\n<iframe style='width:100%;background-color: white;' height=370 src='http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/php_return_or_not.c-GETME' title='C'><\/iframe>\n<\/div>\n<div style='height: 400px;'>PHP<br \/>\n<iframe style='width:100%;background-color: white;' height=370 src='http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/php_return_or_not.php-GETME' title='PHP'><\/iframe>\n<\/div>\n<div style='height: 400px;'>Python<br \/>\n<iframe style='width:100%;background-color: white;' height=370 src='http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/php_return_or_not.py-GETME' title='Python'><\/iframe>\n<\/div>\n<div style='height: 330px;'>Perl<br \/>\n<iframe style='width:100%;background-color: white;' height=300 src='http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/php_return_or_not.perl-GETME' title='Perl'><\/iframe>\n<\/div>\n<div style='height: 380px;'>Javascript<br \/>\n<iframe style='width:100%;background-color: white;' height=240 src='http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/php_return_or_not.js-GETME' title='Javascript'><\/iframe><br \/>\n<br \/>\nLive Run use of Javascript<br \/>\n<iframe style='width:100%;background-color: white;' height=120 src='http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/php_return_or_not.html' title='HTML using Javascript'><\/iframe>\n<\/div>\n<p>For an explanation of PHP&#8217;s flexibility with return values, take a read of this <a target=_blank title='PHP return information' href='http:\/\/php.net\/manual\/en\/functions.returning-values.php'>interesting read<\/a>.<\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d22173' onclick='var dv=document.getElementById(\"d22173\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/function\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d22173' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Our mention of the WordPress function wp_title( &#8216;|&#8217;, true, &#8216;right&#8217; ) in Search Engine Optimization Meta Description Primer Tutorial, with its dual mode (function) return or no return (for display only) modes of use, reminded us of the &#8220;easy&#8221; ways &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/functions-with-or-without-return-primer-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,37],"tags":[1885,176,471,576,644,652,1886,916,932,997,1012,1319],"class_list":["post-22173","post","type-post","status-publish","format-standard","hentry","category-elearning","category-tutorials","tag-argument","tag-c","tag-function","tag-html","tag-java","tag-javascript","tag-parameter","tag-perl","tag-php","tag-programming","tag-python","tag-tutorial"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/22173"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=22173"}],"version-history":[{"count":15,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/22173\/revisions"}],"predecessor-version":[{"id":22213,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/22173\/revisions\/22213"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=22173"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=22173"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=22173"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}