Is the weak type good? Fortunately, I don't know

Source: Internet
Author: User
Is the weak type good? Fortunately, I don't know what I need because I started php. it makes me more and more confused. & nbsp; the code is full of ifemptyifempty & nbsp; if (! Empty ($ CFG-& gt; aaaa) {}& nbsp; & nbsp; search for $ CFG-& gt; aaaa never showed up, vomit blood on the spot, then, how about the weak type? Fortunately, I don't know
I started to use php because of public needs. it is becoming more and more boring to me.

If empty is everywhere in the code
If (! Empty ($ CFG-> aaaa )){}
Search for $ CFG-> aaaa, and vomit blood on the spot.

In addition, the following forms of code are everywhere, nausea
If () {} else {
If (){

} Else {

}
}

The most depressing thing about me is
$ A = NULL;
$ A-> a = 'BBB'; that's all right. NULL is meaningless, so you can skip stdClass.

Weak types are so elegant in javascript, but so disgusting in php.
Since then, I fell in love with the undefined variable exception in js, at least the interpreter prompts me.

This variable that can be used without declaration brings endless pain to debugging and reading.

Complaints are all complaints, and blood is still necessary to vomit. please advise php programming, so you may be able to vomit less.

Is php's programming mode isolated from display and processing pages?
Or are all the same pages determined using if else?

If yes, how does one achieve server jump? That is, the execution process in a request goes through multiple pages, require or include?






------ Solution --------------------
Both Strong and Weak types have their own advantages and disadvantages. they cannot be generalized. strong compilation is of high quality and the code runs fast. The weak type is more flexible.
Although php is a weak language, good practice tells us that initialization before using variables is a good habit, which is not only easy to read, but also can avoid many inexplicable errors.
In addition, php development is fast and lightweight. if a strong type is used, it violates its original intention.
------ Solution --------------------
Is it better to process and display pages separately? As for jump, the framework is basically used now... I recently switched to php. the weak type does make me very uncomfortable, but I like the key-making array with keywords, which is very useful ~
------ Solution --------------------
If you are not used to it, remember to initialize the variables in your own code.
------ Solution --------------------

Is php's programming mode isolated from display and processing pages?
Or are all the same pages determined using if else?

Php has many excellent mvc frameworks
------ Solution --------------------
PHP weak types are easy to use. If you think it is disgusting, you just don't get started.
At least, the weak type is easy to use. now we use the OOP mode to develop and declare the member attributes in the class for ease of management.
Again, the number of variables on a page is limited, and the number of variables cannot be tracked.
If you are not used to this mode, you can: enable PHP errors to all levels, and then set the variables to initialization.

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.