Learn PHP from the Best Tutors
Search in
There are somany cool PHP tricks. Hope below tricks help you a little.
1)Instead of array(), use the shorter [] syntax:
Example:
$fruits = ['apple', 'banana', 'cherry'];
2)Null Coalescing Operator (??)(This operator is useful for handling default values. It returns the first operand if it's not null, otherwise, it returns the second operand)
Example:
$username = $_GET['user'] ?? 'guest';
3) Ternary Operator Simplification
Example:
$age = $userAge ?: 18; // If $userAge is falsey, $age will be 18
5)Type Declarations(PHP 7 and later support type declarations for function arguments and return values:)
Example:
function add(int $a, int $b): int {
return $a + $b;
}
These tricks can help make your PHP code more concise, readable, and efficient.
read lessRelated Questions
Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com
Ask a QuestionRecommended Articles
Why Should you Become an IT Consultant
Information technology consultancy or Information technology consulting is a specialized field in which one can set their focus on providing advisory services to business firms on finding ways to use innovations in information technology to further their business and meet the objectives of the business. Not only does...
Learn Microsoft Excel
Microsoft Excel is an electronic spreadsheet tool which is commonly used for financial and statistical data processing. It has been developed by Microsoft and forms a major component of the widely used Microsoft Office. From individual users to the top IT companies, Excel is used worldwide. Excel is one of the most important...
Make a Career as a BPO Professional
Business Process outsourcing (BPO) services can be considered as a kind of outsourcing which involves subletting of specific functions associated with any business to a third party service provider. BPO is usually administered as a cost-saving procedure for functions which an organization needs but does not rely upon to...
8 Hottest IT Careers of 2014!
Whether it was the Internet Era of 90s or the Big Data Era of today, Information Technology (IT) has given birth to several lucrative career options for many. Though there will not be a “significant" increase in demand for IT professionals in 2014 as compared to 2013, a “steady” demand for IT professionals is rest assured...
Looking for PHP Classes?
Learn from the Best Tutors on UrbanPro
Are you a Tutor or Training Institute?
Join UrbanPro Today to find students near youThe best tutors for PHP Classes are on UrbanPro
The best Tutors for PHP Classes are on UrbanPro