Wednesday, 15 November 2017

Ten Awesome Things Most People Don't Know About PHP

We as a whole know the enchantment traps, and we as a whole know the cool little capacities. We as a whole know the best approach to influence dates to look cool and numbers look great.

1.In part Validate Email Addresses before doing any diligent work

This is exceptionally cool when sending messages for instance. Ought to checkdnsrr() return false while you are endeavoring to send an email with this capacity.

2.Test Boolean Results with Switch

We as a whole realize that we can utilize change to test cases, this way:
<?php
switch ($a) {
case 'a':
resound 'Whoopee it is A';
break;
case 'b':
resound 'Yippee! Its B!';
break;
}

3.Variable Variables

This is my favorite accidental find in programming. What it comes down to is that a variable can have a variable name. Where would you use something like this? Well, image we have a class name that is dependent on the url in some way.

4.MySQLI

On the off chance that you haven't utilized mysqli yet, you truly need to begin contemplating it. Mysqli takes the fundamental mysql  capacities that you more often than not wind up changing 500 times amid an undertaking, or on the off chance that you are more clever, you are making capacities for, and lays them out on a table for you - prepared to utilize.

5.Turn Off Error Reporting

Truly. When you go into generation on your site, execute the mistake revealing. You would prefer not to put every one of your notices and mistakes out there for all humanity to see. Essentially set error_reporting(0); and all is well with the world

6.You don't always need the closing PHP Tag

 It's true. In fact, Zend Framework forbids it. PHP does not require you to close a PHP tag that is at the end of a file, or is in a file that contains only PHP. In other words, you don't need the '?>' unless you need to use non-PHP code after some PHP.

7.Extract is your friend

 Ever been in the situation where you need to say something like:

<?php
$name = $array['name'];
$surname = $array['surname'];
$message = $array['message'];

Then you may want to recall that you can use extract() to do the same.
Put simply, extract will remove the work behind this.
.
Of course, you always need to be mindful of validation and filtering, but there is a right way and a wrong way to do anything with PHP.


8.Comment Comment Comment

 If you don't comment your code, then you should, because no one is going to take you seriously as a developer until you do. It's that simple.

9. Validate
Validation is not only important, it should be mandatory. You need to validate all inputs, and outputs, and make sure that the code you are using is the best possible code it can be. There is nothing else more important.


10. Code Every Day, Build Real Things.
What this means is that he developed something real, something tangible that people would use. By thinking like this, he made it the best way he knew how. You need to do the same. Developing an application that doesn't do anything and is never going to be used by anyone is not going to make you great.
Building something that you know has to work, has to WOW people, and make people want to pay to use it or buy it WILL make you great. At very least it will make you learn something.

No comments:

Post a Comment

JAVA INTERVIEW QUESTIONS AND ANSWERS

Are Looking for Java Training? Learn Advanced Java Besant advances – Only Institute with Oracle Authorized Java Training Center...