Hier im Forum bekommt ihr bei euren fragen schnelle hilfe.Hier geht es rund um das Web SeitenProgrammieren.Alles rund ums Javascript,Html,Php,Css und Sql.Auf fast allen Fragen haben wir eine Antwort.
Der Soforthilfe-chat verspricht das ,was sein Name sagt. Hier sind Leute Online die sofort ihre hilfe anbieten.Seht in der OnlineListe nach und wenn einer Online ist werdet ihr auch antwort bekommen. Admine ,Moderatoren und Helfer sind unsere Spezialisten in Sachen Web Programierung
4 Unwetterwarnungen in Deutschland
Die Datenbank wurde zuletzt am 19.09.2020 01:20:04 aktualiesiert

echo mit “ oder ‚ – was ist schneller?

echo oder print, “ oder ‚ machen nun wirklich keinen bemerkenswerten Performanceunterschied aus

Ob das stimmt habe ich dann mal genauer untersucht. Hier ein Code-Schnipsel, in dem je nach Test das „echo“ durch „print“ bzw das “ durch ‚ ersetzt wurde. Es wurde bewusst nicht alles in ein Testscript geschrieben, weil festgestellt gewurde, dass immer die Tests, die im hinteren Teil des Scripts standen unglaubwürdig lange gebraucht hatten:

 $t=microtime(true); for ($x=0;$x<1000;$x++)   {    echo "JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ  JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ  JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ  JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ  JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ  JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ  JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ  JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ  JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ  JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ  JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ  JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ  JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ";  } echo '
'.(microtime(true)-$t).' s';

Ergebnis:

Echo und „: ca. 2,5s
Echo und ‚: ca. 2,1s
Print und „: ca. 2,5s
Print und ‚: ca. 2,1s

Fazit

Mam kann keinen Performance-Unterschied zwischen Print oder Echo feststellen. Der Unterschied zwischen “ und ‚ ist auf jedenfall vorhanden – wenn auch nicht groß (Man darf nicht vergessen, dass ich zum Testen einen Extremfall (extrem viel Text) verwendet wurde).