Friday 24 May 2019

10 Awesome Things Most People Don’t Know About PHP

The magic tricks, We all are aware of the way to make dates look cool and numbers look awesome. But there are a few things which most people don’t think about, and I’m one of them. As I started working on this article, I did a little R & D and found a few things which will make me change the way why I use PHP. Let’s dive right in for further details!

1) Validating Partially the Email Addresses before doing any hard work.
PHP has an inbuilt function called checkdnsrr() which will take an email address and check if it resolves as an IP address. This is very cool for example when we are sending emails. checkdnsrr() should return false while you are trying to send an email with this function, and you can return an error notifying the user that domain probably doesn’t exist before you do anything else. This is great that you didn’t really even have to validate the email address in any other way, saving you server resources, time, and just making things really better. Of course, you should do the usual slog and validate with filters, but this is a good way to actually see of the domain and email address actually exist.
2) Test Boolean Results with Switch. We all know that we can use the switch to test cases, like this:
<?php
switch ($a) {
case ‘a’:
echo ‘Yay it is A’;
break;
case ‘b’:
echo ‘Yahoo! Its B!’;
break;
}
But did you know you can also test for Boolean values with a switch? The trick is to use it as follows:
<?php
switch (TRUE) {
case ($a == ‘A’):
echo ‘Yay it is A’;
break;
case ($a == ‘B’):
echo ‘Yahoo! Its B!’;
break;
}
The principle might not strike your mind until you think about it, but once it does it’s very clear that switch can actually make things very simple for you if you use it in this way as well.

Learn More... https://www.iihglobal.com/blog/most-people-dont-know-about-php/

1 comment:

Which company provides retail industry software?

In today’s era retail industry, brands must know how to manage and leverage a large level business. Whether a customer is researching...