The online racing simulator
PHP Script help
(16 posts, started )
PHP Script help
Fixed
So the error was happening when I seperated these two like this so that it would fix an error with the <font color =green> html code not working. Then from there php was telling me the fix. To add a comma between the " and '. Thus it was fixed. Im a newbie at php by the way.

echo "$ServerName is "'<font color="green">Online</font><br>';
The better way to fix it would have been:

echo $servername . " is <font color=\"green\">Online</font><br />";
or echo $servername . ' is <font color="green">Online</font><br />';
thirdly a echo "$servername is <font color=\"green\">Online</font> <br />";

Either of them would fix that issue. The comma that you're using isn't quite proper.. a period would be correct though. (The period concatenates the strings.)

<?php 
echo $ServerName' is <font color=\"green\">Online</font><br />';
?>

would be the most efficient solution, saves you the string concatenation.
Really? You can pass freaking echo muliple argumenets? That's such a oddity.
Quote from dawesdust_12 :Really? You can pass freaking echo muliple argumenets? That's such a oddity.

You can and you should (if you care about the few nanoseconds) whenever it's possible instead of concatenation, although opcode caches (accelerators / optimizers, whatever you want to call them) nullify the advantage.
echo, being the odd language construct it is, does things a bit differently from regular functions and even its fellow language constructs.
Hm.. I'll keep that in mind the next time I write a large Project...
Quote from dawesdust_12 :Hm.. I'll keep that in mind the next time I write a large Project...

Well, to be frank, my big projects all use a template engine and end up having only a single echo echo'ing a large string anyway. It's a neat performance booster to keep in mind for CLI (PRISM :razz or smaller, inline-markup'd projects though.
Yeah, but I don't write template engines :P I do develop websites using one, that's developed in house by my workplace though.
Quote from morpha :

<?php 
echo $ServerName' is <font color=\"green\">Online</font><br />';
?>

would be the most efficient solution, saves you the string concatenation.

Agreed, with the options given. Although I have no idea if HereDoc would be faster overall.


Quote from morpha :It's a neat performance booster to keep in mind for CLI (PRISM :razz or smaller, inline-markup'd projects though.

Your really quite excited about PRISM aren't you?
Quote from Dygear :Agreed, with the options given. Although I have no idea if HereDoc would be faster overall.

Here's a good read on the whole subject, including an objective opcode comparison rather than so-so microbenchmarks you usually see.

Quote from Dygear :Your really quite excited about PRISM aren't you?

I just want to see how far we can push PHP
Quote from morpha :Here's a good read on the whole subject, including an objective opcode comparison rather than so-so microbenchmarks you usually see.

Over 160 BILLION packets, a few nanoseconds can build up to real time. Assuming you save 2ns from each operation, and on each packet you use the string operator once, you could save 320 seconds over the course of the applications run time. That's five minutes and 20 seconds. Considering that one second is equivalent to 31.7 years, stupid small optimizations can make a huge difference over the lifetime of your application.

Quote from morpha :I just want to see how far we can push PHP

Indeed. Got any tricks up your sleeve?
I say you hurry up too. I need to write my awesome cruise insim
Quote from dawesdust_12 :I say you hurry up too. I need to write my awesome cruise insim

morpha never said hurry up ... At least, I did not read it.
Shh.. Semantics.. all this analysis of my English means you're writing less PHP

PHP Script help
(16 posts, started )
FGED GREDG RDFGDR GSFDG