Tech Talk : PHP – Nifty & Nice Part 01

Xybernetics PHP Programming Tips Nifty and NiceHere are some of the collection of cool coding techniques in PHP and at times in other programming platform from all around the web. Hope you enjoy it.

Array – Best way to clear a PHP array values.
Use unset, if you need the array later on just instantiate it again.

Array – Return an array from a function.
If you have a function and you would like to return multiple values from it, then you would code like this.

And to retrieve the values returned from a function, you would use this code.

Value from $aVar1 is assigned to $var1 and value from $aVar2 is assigned to $var2.

Alternatively, you can store it as an array.

Value from $aVar1 is assigned to $returnVar[0] and value from $aVar2 is assigned to $returnVar[1].

Shorthand If/Else in PHP
.
Basic True/False Declaration

Conditional Greeting Message

Conditional Error Reporting Level

Conditional Basepath

Nested PHP Shorthand

Leap Year Check

Conditional PHP Redirect

Reference

Leave a Reply

Your email address will not be published. Required fields are marked *