Weak type okay? I don't know, brother.

Source: Internet
Author: User
Weak type okay? Well, I don't know.
Because of the public needs, the start of PHP, it more and more let me feel nausea.

The code is everywhere if empty if empty
if (!empty ($CFG->aaaa)) {}
Search for a $cfg->aaaa never appeared, the spot vomiting blood, and then spit a few times will not vomit.

In addition, everywhere is the following form of code, nausea
if () {}else{
if () {

}else{

}
}

The most depressing thing to me is
$a = NULL;
$a->a = ' BBB '; So altogether yes, NULL is meaningless, you can not use Stdclass completely.

Weak typing is so elegant in JavaScript that it's so disgusting in PHP
Since then I fell in love with the undefined variable exception in JS, at least the interpreter prompted me.

This non-declarative variable can be used to debug, reading brings untold pain.

Complain to complain, blood or to continue to vomit, please master teach PHP programming way, this may be less spit.

Is the programming mode of PHP separate from the display page and the processing page?
Or is it the same page, using if else to judge?

If it is detached, how to implement server-side jump? That is, executing the process within a single request through multiple pages, require or include?






------Solution--------------------
Strong type or weak type, have their own advantages and disadvantages, not generalize, strong type compilation quality, code run fast. Weaker types are more flexible.
Although PHP is a weakly typed language, good practice tells us that initializing before using variables is a good habit, not only for readability, but also for avoiding many inexplicable errors.
Moreover, the advantage of PHP development is fast, lightweight, if the use of strong type, it is precisely violated its original intention.
------Solution--------------------
Is it better to process the page and show the page or separate it? As for the jump is now basically a frame ... I also just transferred to PHP soon, the weak type really let me very unaccustomed, but I like to use the key to do the key array, very useful ~
------Solution--------------------
If you're not used to it, remember to initialize the variables in the code you wrote.
------Solution--------------------

Is the programming mode of PHP separate from the display page and the processing page?
Or is it the same page, using if else to judge?

PHP has a lot of good MVC frameworks
------Solution--------------------
PHP's weak type is very convenient to use. As you feel it disgusting, it's just that you're not getting started.
At the very least, the weak type is clean, and now we are developing it in OOP mode, which can be managed by centralizing the member properties in the class.
Think again, in a page, the number of variables is limited after all, not so that people can not trace the point of the variable.
If you're really not used to this pattern, you can do this: start PHP with the wrong level, and then set the variables together and initialize them.

eg
PHP Code
  
   
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.