Tweak perf example in The Basics

This commit is contained in:
=
2012-08-10 13:42:40 -04:00
parent 084bf61fdd
commit 26628985dd

View File

@@ -307,16 +307,16 @@ echo ($a == 5) ? return true : return false; // this example will output an e
At times, coders attempt to make their code "cleaner" by declaring predefined variables with a different name. What
this does in reality is to double the memory consumption of said script. For the example below, let's say
$_GET\['about_me'\] contains 1MB worth of data, by copying the variable you've increased the scripts execution to 2MB.
an example string of text contains 1MB worth of data, by copying the variable you've increased the scripts execution to 2MB.
{% highlight php %}
<?php
$about = $_GET['about_me']; // uses 2MB memory
$about = 'A very long string of text'; // uses 2MB memory
echo $about;
vs.
echo $_GET['about_me']; // uses 1MB memory
echo 'A very long string of text'; // uses 1MB memory
{% endhighlight %}
* [Performace tips](https://developers.google.com/speed/articles/optimizing-php)