Q&A

# Tips in golfing using PHP

+1
−0

This is a list of golfing tips for the language known as Philippine Peso PHP. If you have a tip, add it in!

Why does this post require moderator attention?
Why should this post be closed?

+1
−0

# Use <?=

It's basically the same as <?php echo.

Used on Reverse an ASCII string.

Why does this post require moderator attention?

+1
−0

# Anything that's outside the script is echoed

This probably has to deal with the fact that PHP is a script commonly used on HTML, and anything that is written on the HTML document--not inside the script--is outputted.

Used on "Hello, World!".

Why does this post require moderator attention?

+1
−0

# Remove ?>

You can save 2 bytes by removing the syntax that ends the PHP script when you don't need it. The program will still work.

<?php echo"Hello!";


Try it online!

Why does this post require moderator attention?

+1
−0

# Whitespace can be removed in between keywords and variables

You can easily remove the whitespace that's in-between a keyword (return or a function that doesn't need parentheses) and a variable (either starting with $ for the variable's name or " if the variable to deal with is a string): <?php$x=9+10;echo"Hello!\n";echo$x;  Try it online! Why does this post require moderator attention? You might want to add some details to your flag. #### 0 comment threads +0 −0 # Set arrays without array() In a few occasions, setting an array using array() can be a bit costly. Thankfully, you can assign an array like how to assign a Python list. <?php$a=["Hello","MarkFuncs","Golfing"];print_r(\$a);


Try it online!

Why does this post require moderator attention?