{"id":145,"date":"2011-12-24T15:08:31","date_gmt":"2011-12-24T15:08:31","guid":{"rendered":"https:\/\/ibex.tech\/cloud\/?p=145"},"modified":"2022-02-17T07:14:05","modified_gmt":"2022-02-17T07:14:05","slug":"variables","status":"publish","type":"post","link":"https:\/\/ibex.tech\/cloud\/php\/memory\/variables","title":{"rendered":"Variables"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Variables General<\/h4>\n\n\n\n<p>Variable names must start with a &#8216;$&#8217; character (to allow the php parser to work as fast as possible by instantly know it is a variable).<\/p>\n\n\n\n<p>A variable name must start with a letter of the alphabet or and underscore &#8216;_&#8217;.<\/p>\n\n\n\n<p>Variable names may only contain: &#8216;a&#8217; &#8211; &#8216;z&#8217;, &#8216;A&#8217; &#8211; &#8216;Z&#8217; and &#8216;_&#8217;<\/p>\n\n\n\n<p>Variable names are case sensitive.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Variable Types<\/h4>\n\n\n\n<p>PHP will always convert a variable to the type requried by the contect it is being used in.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$number = 12345 &amp; 67890;\u00a0\u00a0 \/\/$number is used as a numeric varaible\necho substr ($number, 3, 1);   \/\/$number is used as a string<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Static Variables<\/h4>\n\n\n\n<p>Use in functions to retain a value between calls.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>static $LastPostTitle = \"\";<\/code><\/pre>\n\n\n\n<p>Note that whilst you can assign an initial value, it must not be the result of an expression (e.g. &#8220;= 2 + 4&#8221; is not allowed)<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Global Variables<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>global $ProductCodeName;<\/code><\/pre>\n\n\n\n<p>Every line of code in your program can access a global variable.<\/p>\n\n\n\n<p>Note that you can&#8217;t use = when declaring a global variable.\u00a0 Assign the value seperately.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Integers<\/h4>\n\n\n\n<p>Integer size is platform-dependent, safest is to assume a maximum value of about two billion (32 bits signed).<\/p>\n\n\n\n<p>64-bit platforms usually have a maximum value of about 9E18<\/p>\n\n\n\n<p>Unsigned integers are not supported in PHP<\/p>\n\n\n\n<p>If PHP encounters a number, or the result of an operation, that is beyond the bounds of the integer type, it will be interpreted as a float instead.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Variables General Variable names must start with a &#8216;$&#8217; character (to allow the php parser to work as fast as possible by instantly know it is a variable). A variable name must start with a letter of the alphabet or and underscore &#8216;_&#8217;. Variable names may only contain: &#8216;a&#8217; &#8211; &#8216;z&#8217;, &#8216;A&#8217; &#8211; &#8216;Z&#8217; and [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27],"tags":[],"class_list":["post-145","post","type-post","status-publish","format-standard","hentry","category-memory"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/145","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=145"}],"version-history":[{"count":9,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/145\/revisions"}],"predecessor-version":[{"id":2695,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/145\/revisions\/2695"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/media?parent=145"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/categories?post=145"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/tags?post=145"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}