{"id":5713,"date":"2019-11-14T10:49:21","date_gmt":"2019-11-14T15:49:21","guid":{"rendered":"https:\/\/www.rushworth.us\/lisa\/?p=5713"},"modified":"2019-11-14T10:49:21","modified_gmt":"2019-11-14T15:49:21","slug":"modifying-shared-php-function","status":"publish","type":"post","link":"https:\/\/www.rushworth.us\/lisa\/?p=5713","title":{"rendered":"Modifying Shared PHP Function"},"content":{"rendered":"<p>We needed to modify a shared function to include additional information &#8230; but didn&#8217;t want to coordinate changing <em>all<\/em> of the calls to the function as one change. Simplest way to accomplish that was to set a default value for the new parameter &#8212; either to NULL and just not do the new thing when the parameter is NULL or some value that indicates that we&#8217;re not yet gathering that data.<\/p>\n<pre>&lt;?php\r\n\r\nfunction testFunction($strOldParameter, $strNewParameter=NULL){\r\n     echo \"The old parameter is |$strOldParameter|\\n\";\r\n     if($strNewParameter){\r\n          echo \"The new parameter is |$strNewParameter|\\n\";\r\n     }\r\n}\r\n\r\ntestFunction(\"first\", \"second\");\r\ntestFunction(\"justFirst\");\r\n\r\n?&gt;<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>We needed to modify a shared function to include additional information &#8230; but didn&#8217;t want to coordinate changing all of the calls to the function as one change. Simplest way to accomplish that was to set a default value for the new parameter &#8212; either to NULL and just not do the new thing when &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33],"tags":[35],"class_list":["post-5713","post","type-post","status-publish","format-standard","hentry","category-coding","tag-php"],"_links":{"self":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/5713","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5713"}],"version-history":[{"count":1,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/5713\/revisions"}],"predecessor-version":[{"id":5714,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/5713\/revisions\/5714"}],"wp:attachment":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5713"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5713"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5713"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}