Copy or not copy, i.e. a variable?

I landed on this link: https://developers.google.com/speed/articles/optimizing-php

And then he searched the variable copies and found the following: To copy or not to copy additional variables in PHP?

So, I understand the above concepts, but as far as I understand, the code below is actually good practice, but sorta contradicts the instructions not to copy. Its almost like "not copying" should have a condition. Ive always understood that making a function call in each cycle is more resource intensive than storing (copying).

$total = total();
for($i=0; $i<$total; $i++){
}

The same goes for (the best example I could come up with for a Google example):

<?php
$description = strip_tags($_POST['description']);
?>
<img src="" alt="<?php echo $description ?>" title="<?php echo $description ?>" data-description="<?php echo $description ?>" />

, :

<img src="" alt="<?php echo strip_tags($_POST['description']) ?>" title="<?php echo strip_tags($_POST['description']) ?>" data-description="<?php echo strip_tags($_POST['description']) ?>" />

, , " " ?

+4
3

google, , Hoare dictum Premature optimization is the root of all evil.

( ) , . , . , , ( , ), .

, , , , . , , .

+2

, - , , . 99,99999% . , , -. , , -, . Google, , , , -, .

+9

, , . . :

<img src="" alt="<?php echo strip_tags($_POST['description']) ?>" title="<?php echo strip_tags($_POST['description']) ?>" data-description="<?php echo strip_tags($_POST['description']) ?>" />

strip_tags 3 . , , . "strip_tags" php " ", 3 : (

Google :

$description = strip_tags($_POST['description']);
echo $description;

.

, 2 , . , .

: ( ). , . .

+1
source

All Articles