Skip to main content

Timeline for Tips for golfing in PHP

Current License: CC BY-SA 3.0

10 events
when toggle format what by license comment
Oct 11, 2017 at 13:49 comment added Ismael Miguel @Titus I didn't said anything about print.
Oct 10, 2017 at 8:00 comment added Titus @IsmaelMiguel It works with echo, but not with print (which you need if you put it inside an expression: echo is a pure construct with no return value while print can act as a function: it requires no parentheses, but it always returns int(1).
Apr 7, 2017 at 7:59 comment added Ismael Miguel @BasicSunset That statement can be written as echo$a+5," text";. The echo construct allows you to pass multiple parameters. where one would have to write echo"result: ".($a+5)."!";, you can write echo"result: ",$a+5,"!";. In fact, passing multiple parameters to an echo is a micro-optimization, since the code will run a tiny bit faster (since you don't concatenate the output, but send it separately). For challenges about writting the fastest code, this may help a tiny tiny tiny bit.
Aug 16, 2016 at 14:47 comment added Business Cat Another instance where you need whitespace is in string concatenation. For instance, echo $a+5." text" will not work because PHP thinks the . is a decimal point for the 5. To make it work, you would need to add a space like this: echo $a+5 ." text"
Jul 22, 2016 at 19:05 comment added Titus foreach($a[1]as$b) needs no white space. This is not about language constructs and variables, but about spaces between word-characters of different words.
Feb 20, 2015 at 2:53 history wiki removed Doorknob
May 24, 2013 at 18:34 history edited Gaffi CC BY-SA 3.0
Minor grammatical adjustment, changed formatting to be consistent.
Sep 2, 2011 at 2:36 vote accept JiminP
Aug 29, 2011 at 19:59 history edited Gerry CC BY-SA 3.0
It appears that the word used was incorrect "variable" instead of "space"
Jun 20, 2011 at 14:26 history answered rintaun CC BY-SA 3.0