Low cost ecommerce web development India flash website design

Performance Issues

Depending on the scale of your application, there are some performance issues

you might need to consider when using references

Performance Issues

In simple cases of copying one variable to another PHP's internal reference

counting feature prevents unnecessary memory usage. For example,

$a = 'the quick brown fox';

$b = $a;

In the above example, the value of $b would not take up any extra memory, as

PHP's internal reference counting will implicitly reference $b and $a to the same

location in memory, until their values become different. This is an internal feature

of PHP and affects performance without affecting behavior. We don't need to

worry about it much.

In some cases, however, using a reference is faster, especially with large arrays

and objects, where PHP's internal reference counting can't be used. and the

contents must therefore be copied.

So, for best performance, you should do the following:

_ With simple values such as integers and strings, avoid references whenever

possible.

_ With complex values such as arrays and objects, use references whenever

possible.

References and PHP 5

With PHP 5, references will cease to be an issue because the default behavior of

PHP, when passing objects, will be to pass by reference. If you ever need a copy

of an object, you can use the special __clone method to create copies.

Essentially, the change brings PHP in line with the majority of object oriented

programming languages like Java, and will certainly do a lot to reduce the confusion

surrounding the subject. For now, though, and until PHP 5 has been widely

adopted, knowing how references work is important.

 

website designer freelance ASP PHP ecommerce web developer
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110