9da317225001a96afabcfc4b45d3a2f6

Standard PHP Ausgabe mti Variable

1
2
3
4
5
6
7
<?php

$name = "test";

echo "Die ist ein : " . $name;

?>

Refactorings

No refactoring yet !

5a00a3a98dcf6f9cd717440fd2b606e5

Eineki

June 2, 2009, June 02, 2009 10:41, permalink

No rating. Login to rate!

maybe you can use the comma (,) instead of dot (.) you save the unnecessary concatenation (somewhere I read it is somewhat quicker)

1
2
3
4
5
6
7
<?php

$name = "test";

echo "Die ist ein : " , $name;

?>
9da317225001a96afabcfc4b45d3a2f6

okais.myopenid.com

June 2, 2009, June 02, 2009 12:06, permalink

No rating. Login to rate!

ok,

I knew it only with the "." .I've never seen "," ;)

A8d3f35baafdaea851914b17dae9e1fc

Adam

June 2, 2009, June 02, 2009 14:56, permalink

No rating. Login to rate!
1
2
3
4
5
6
7
<?php

$name = "test";

echo "Die ist ein : $name";

?>
Avatar

bob

June 2, 2009, June 02, 2009 17:53, permalink

No rating. Login to rate!
1
2
3
4
5
6
7
<?php

$name = "test";

echo "Die ist ein : $name";

?>
Avatar

Anonymous

June 2, 2009, June 02, 2009 20:02, permalink

No rating. Login to rate!

Two ideas:

If $name is a constant, don't make it look like a variable.

If $name can in any way modified by the user, don't forget to remove all HTML markup (and adapt the encoding to your page's, if necessary)

Handing two arguments to "echo" instead of concatenating the arguments yourself gives you a marginal speed boost, but in general I wouldn't worry about that.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php

define("NAME", "test");

echo("Die ist ein : ", NAME);

?>

-or-

<?php

$name_raw = "test";
$name = htmlspecialchars($name_raw, ENT_NOQUOTES, 'UTF-8')

echo("Die ist ein : ", $name);

?>

Your refactoring





Format Copy from initial code

or Cancel