Some Questions about PHP

Source: Internet
Author: User
Tags php language
Today by PDO's Lastinsertid toss an afternoon, is really drunk, using exec execution insert causes Lastinsertid to return is always 0, must use Prepare/execute to obtain normally.

A lot of times I think PHP why so casual ah, empty/isset/is_null, hey, it's so damn wonderful (I will be rough how, can not endure). May be the cause of history, or there are some reasons I do not know why please point out, has been very strange when the original design why can not be: is_empty/is_set/is_null, or: Isempty/isset/isnull? This example is also reflected in the Str class function, which also has the problem of parameter order, such as Str_replace target string in the back, substr/strpos in front, I would like to ask, how can a language at random to this degree?

There are also type conversion, every time you get the value of the user passed a little afraid of it, a lot of methods do not add strict are afraid to use it, I asked you why this, you said: because I "weak" Ah! You see as long as you do not have to = =, judge I can disappear run down!

The rest is abnormal, predictable or exit/die, tall on a bit of exception, but most of the exception also want me to throw it. This is not over, my lord, you still have the error, there is a grade, the exception is not caught, to make a springboard it.

Reply content:

Today by PDO's Lastinsertid toss an afternoon, is really drunk, using exec execution insert causes Lastinsertid to return is always 0, must use Prepare/execute to obtain normally.

A lot of times I think PHP why so casual ah, empty/isset/is_null, hey, it's so damn wonderful (I will be rough how, can not endure). May be the cause of history, or there are some reasons I do not know why please point out, has been very strange when the original design why can not be: is_empty/is_set/is_null, or: Isempty/isset/isnull? This example is also reflected in the Str class function, which also has the problem of parameter order, such as Str_replace target string in the back, substr/strpos in front, I would like to ask, how can a language at random to this degree?

There are also type conversion, every time you get the value of the user passed a little afraid of it, a lot of methods do not add strict are afraid to use it, I asked you why this, you said: because I "weak" Ah! You see as long as you do not have to = =, judge I can disappear run down!

The rest is abnormal, predictable or exit/die, tall on a bit of exception, but most of the exception also want me to throw it. This is not over, my lord, you still have the error, there is a grade, the exception is not caught, to make a springboard it.

Do not meet a bit of frustration on the negation of good or bad. By PDO toss the afternoon to explain that you are not familiar with PHP, even if not familiar with, there is no manual, will not Baidu, online find a complete available example read and write it? This can also blame PHP? In the phrase: "I am also drunk." Would you like to find some more questions from yourself, please?

You say the function name is not unified, the problem is more chaotic, itself is a historical reason, PHP, many users, a lot of things are not said to change. Of course, with the passage of time, we now slowly see the progress of PHP, PHP7.0 is about to release, it does the performance optimization and new additions to the features, are worthy of our expectations.

Used to be Java, now with PHP is almost 3 years, there is no feeling weak type what bad, accustomed to you can completely control it.

Sometimes it's okay to whine, especially when you're not familiar with it. But a language you choose it, is to fancy its advantages. Always stare at it's bad also how to learn, how to progress. If you feel that it is not good, you can try to find a way to solve or make up for it is not good, of course, if you spend more time to understand it.

Now that you report me irrelevantly replying, I'll change it. Re-read the question of the main problem, a lot of spit in the groove inside a question: "I would like to ask, how can a language at random to this extent?" "The feeling of the Lord is to seek identity, not to seek doubts." Very want to anti-problem master: How can ask questions to be free to this degree?

The high level of inconsistency in the PHP language does make a lot of people vomit, which is true, and the root cause of this is that PHP is not a language designed at all, but a growing language.

That year is a buddy think CGI write Web server program too troublesome, and then on their own to develop a personal web site toolkit, and later dropped to the open source community, people in the community think this toolkit is good, so you add a bit of functionality, I add a bit of functionality to expand the toolkit, Finally evolved into the PHP language. Early PHP is personal Home page abbreviation, later in order to fashion to change into a palindrome type of php:hypertext preprocessor.

Languages such as Ruby, Python, or C # are carefully designed by experienced software developers. The first is to make a programming language suitable for certain scenarios, language consistency is high, the grammatical design is exquisite, flashing the designer's wisdom and experience everywhere. And these languages have been spearheaded by the official team since its release, and the community-contributed code needs to be rigorously vetted to get into the core repository.

However, the early PHP did not have the so-called core Development Group, everyone in the technical newsgroups to exchange views, with FTP share code. PHP interpreter is written in C, we have to all kinds of C language code library into the PHP language functions, so also retained the various schools of function naming rules. And even the first guy to develop and release PHP didn't care, until the 3.0 release, the community had a few people forming a core team to release the official version, but their main job was to coordinate community views and provide bug tracking. The object-oriented model of PHP was made by Zend's developers in the 5.0 era.

Do you feel so messed up? Tell you the truth: not only PHP, the entire web world is a mess. You see the tags in the HTML, why there is full write also have abbreviations, ,</code>这种写法和

      这种写法并存?因为HTML发展之初也是没标准的,早期有过的写法,也有过的写法,不同的个人开发者给出不同的实现罢了,直到有一天,支持第一种写法的浏览器成为绝对主流了,于是才有了标准。

      PHP一直是典型的自由软件的运作方式,先有大家的自由改进,然后互取所长,然后攒出一个较优选择成为官方,然而大把多人在官方基础之上自己改东西,有一些有幸被官方收纳到未来版本人,有一些就沉没了。

      那么怎么解决乱这个问题呢?许多人都提出了解决方案,比如把命名不一致的函数封装到框架里,把empty之类的像函数而又不是函数的语法也封到框架里,把一切混乱包起来,只对开发者暴露出优雅的部分。然而现实情况是PHP语言领域没有一套唯一的框架,世界上的知名PHP开发框架不下20种,各公司各团队自己库和框架更是海了去了。

      PHP最后就和C语言一样,只能靠人来解决这个问题——别写烂代码,尽管语言允许你乱写——选择一种大家喜欢的语言风格,定为团队标准,然后执行它。还有,用一个好的IDE,自动完成提示能把你从记忆各种不同风格的函数中解放出来。

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.