Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
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!

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.
Why should this post be closed?

0 comment threads

5 answers

You are accessing this answer with a direct link, so it's being shown above all other answers regardless of its score. You can return to the normal view.

+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!

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+1
−0

Use <?=

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

Used on Reverse an ASCII string.

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+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!

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+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!".

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+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!

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

Sign up to answer this question »