{"id":3871,"date":"2022-01-19T12:37:30","date_gmt":"2022-01-19T12:37:30","guid":{"rendered":"https:\/\/ibex.tech\/cloud\/?p=3871"},"modified":"2022-02-17T07:13:46","modified_gmt":"2022-02-17T07:13:46","slug":"functions-using-references-pointers","status":"publish","type":"post","link":"https:\/\/ibex.tech\/cloud\/php\/functions\/functions-using-references-pointers","title":{"rendered":"Functions using references\/pointers"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Defining a function argument as a pointer<\/h4>\n\n\n\n<p>Use the &#8216;&amp;&#8217; character in frnt of the function argument definition.<\/p>\n\n\n\n<p>That&#8217;s it, there&#8217;s no other change needed, nothing is prepended to the variable when used or the function argument when called.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function MyFunction (&amp;$MyVariable)\n{\n  $MyVariable = \"abc\" . $MyVariable . \"hij\";\n}\n\n$Name = def;\n\n$Name = MyFunction($Name);\necho $Name;    \/\/Will print \"abcdefhij\"<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Array references<\/h4>\n\n\n\n<p>Works just the same as for variables.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Defining a function argument as a pointer Use the &#8216;&amp;&#8217; character in frnt of the function argument definition. That&#8217;s it, there&#8217;s no other change needed, nothing is prepended to the variable when used or the function argument when called. Array references Works just the same as for variables.<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33,312],"tags":[],"class_list":["post-3871","post","type-post","status-publish","format-standard","hentry","category-functions","category-references"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/3871","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/comments?post=3871"}],"version-history":[{"count":3,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/3871\/revisions"}],"predecessor-version":[{"id":3929,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/3871\/revisions\/3929"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/media?parent=3871"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/categories?post=3871"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/tags?post=3871"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}