Hello
I am seeking suggestions to reduce cpu and memory usage for a couple of code snippets. I have been adding @ because of a large number of undefined variable notices. However I am coming to realize that this is expensive on a busy server.
The first is for an incoming variable:
The second is for mysql:
In some cases I am using isset to check if the variable has been defined. I have been researching ternary operators, but do not exactly understand how to apply them.
In most cases, if the variable is not defined (i.e., not present in the call or database), then the default value could be nothing or null, as long as it is defined and does not cause a notice later.
I have recently moved to a new box, and I **think** on the previous box zend optimizer was obscuring this cpu/memory demand. However for some conflict I have not gotten it to install on the new box. Still working on that front also, but this is really a php question.
Thanks & Cheers
Mike
I am seeking suggestions to reduce cpu and memory usage for a couple of code snippets. I have been adding @ because of a large number of undefined variable notices. However I am coming to realize that this is expensive on a busy server.
The first is for an incoming variable:
Code:
$state = @$_GET['state'];
$city = @$_GET['city'];
$name = @$_GET['name'];
The second is for mysql:
Code:
$id = @$row['id'];
$name = @$row['name'];
$address = @$row['address'];
In some cases I am using isset to check if the variable has been defined. I have been researching ternary operators, but do not exactly understand how to apply them.
In most cases, if the variable is not defined (i.e., not present in the call or database), then the default value could be nothing or null, as long as it is defined and does not cause a notice later.
I have recently moved to a new box, and I **think** on the previous box zend optimizer was obscuring this cpu/memory demand. However for some conflict I have not gotten it to install on the new box. Still working on that front also, but this is really a php question.
Thanks & Cheers
Mike