


Looking ahead to PHP7: What needs to change in PHP_PHP Tutorial
Programmers (generally) define a good programming language as one they know best or use most often. I'm a PHP programmer, John is a JavaScript programmer, DHH is a Ruby programmer, and Schwartz and Randall are Perl programmers. Different programmers look at the problem differently, but there are always one or two that are collectively considered the best.
As a PHP developer, it hurts every time I hear PHP being disrespected.
Although we must use PHP as a language for web applications, it is a bad language and its use should not be encouraged, or supported beyond necessity.
Oops, when I heard that the language I use every day is given a bad evaluation, some people may say that you should not care about other people's evaluation of the language you choose, as long as you agree with it. I guess I really shouldn't, and what that statement implies is that not only does the language suck and the developers suck, but we PHP developers suck too.
So, what exactly should be done to shut down other people’s big mouths? Can we make the PHP language respected? Can we make PHP developers respected? Let’s analyze some aspects where we can do it at this point.
1. Break everything
PHP7 is going to break everything. PHP developers should accept the law of breaking backward compatibility between versions. As long as extensive backward compatibility is not allowed, PHP7 will be a highly respected language.
1. Create a specific core language
Remove all library methods and keep the core methods in the object set. You should be able to write PHP7 without any external libraries or extensions and a nice complete language for basic input/output, string handling and math. Any extension outside of the library should be approved.
2. Treat everything as an object
Take objects from Ruby, Smalltalk and (mainly) Java and treat it all as an object. Integers are objects, strings are objects, and each of them has methods that can be manipulated. I don't believe that PHP needs the notion of Ruby and Smalltalk to pass messages between objects, and calling methods on objects is the best.
3. Consistently named methods and classes
Since one of the biggest complaints about PHP is the constant need to check, (needle,haystack) or (haystack, needle) , or some_function(), or function_some(), or someFunction(), a consistent format needs to be developed.
4. Keep things strict
Try passing a float string into a method? This is a warning.
5. Everything is Unicode
All strings in PHP6 are Unicode, which is good, and I advocate that PHP7 should also be maintained.
6. Central startup point
Create a main class or initialization from which all code execution originates.
7. Clean up C code
I am not a C expert, but if you know more about Ruby’s C code to PHP’s C code, it can be very easy Understand the internals of PHP and Ruby. I'm very familiar with PHP, so writing my own extension is easier.
8. Get rid of eval()
eval() is evil. If you are using it then this is a wrong idea: this will break PHPUnit, discard it from now on.
9. Support operator overloading
Because everything is an object, developers only need to master the methods of operating objects.
10. Allowed method signatures
Allows true method signatures, so programmers can have methods with the same name with different parameter lists or return types.
<ol class="dp-c"> <li class="alt"><span><span class="keyword">class</span><span> A { </span></span></li> <li> <span class="keyword">public</span><span> int </span><span class="keyword">function</span><span> doSomething(int </span><span class="vars">$a</span><span>, float </span><span class="vars">$b</span><span>) { </span> </li> <li class="alt"> <span class="comment">// Same as $a->*($b->to_int()); </span><span> </span> </li> <li> <span>int </span><span class="vars">$c</span><span> = </span><span class="vars">$a</span><span> * </span><span class="vars">$b</span><span>->to_int(); </span> </li> <li class="alt"> <span class="keyword">return</span><span> </span><span class="vars">$c</span><span>; </span> </li> <li><span>} </span></li> <li class="alt"> <span class="keyword">public</span><span> float </span><span class="keyword">function</span><span> doSomething(int </span><span class="vars">$a</span><span>, float </span><span class="vars">$b</span><span>, float </span><span class="vars">$c</span><span>) { </span> </li> <li> <span class="comment">// Same as calling $a->*($b->*($c)); since * is a method on each object $a and $b. </span><span> </span> </li> <li class="alt"> <span>float </span><span class="vars">$d</span><span> = </span><span class="vars">$a</span><span> * </span><span class="vars">$b</span><span> * </span><span class="vars">$c</span><span>; </span> </li> <li> <span class="keyword">return</span><span> </span><span class="vars">$d</span><span>; </span> </li> <li class="alt"><span>} </span></li> <li><span>} </span></li> </ol>
11. Create a PHP Virtual Machine (PVM)
I’m not entirely sure this is possible Yeah, since I'm not a language designer, but it would be nice to have a PHP virtual machine. It can execute PHP bytecode and allows an explicit heap and stack.
12. Delete copy-on-write (COW)
COW is a fairly unfamiliar concept, if you don’t know its existence, to new developers , it may cause problems.
13. PHP official release specification
Similar to the W3C HTML5 specification, the PHP specification will allow developers to implement their own version of PHP and ensure that there are specific examples to Compile.
2. Respect language
Efforts should be made to respect language. We should try our best to recruit developers to make PHP7 with very powerful functions. We should make huge code safe, easy to read, and teach new developers to program the right way.
I don’t know about Ruby’s craziness, but I respect the Ruby language. I see its power, I see Ruby on Rails as a very good framework, it's just not my cup of tea. If we can gain recognition or respect from developers with good prestige, PHP will go further.
3. Respect developers
From the above understanding, we need a very respected PHP development core team. They release code, give talks, and show people the "right way" of doing things, and this team will quickly gain the respect of many developers.
Conclusion
I’m excited about the future of PHP. I highly doubt my ideas will be implemented, but I truly believe they will help society as a whole. I was so excited when the world's second largest website announced that they were helping PHP build great communities. PHP will not disappear, it will get better and better. As long as we work hard to improve it and improve it, one day PHP will become a language generally respected by developers.
Finally, I am not a language designer. My idea may be considered complete nonsense. If I'm incorrect somewhere, please politely let me know and I'll be happy to talk about it. Let's work together to make PHP a well-respected, powerful, fast, and efficient language. If there are any errors in compilation, please correct me!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

Causes and solutions for errors when using PECL to install extensions in Docker environment When using Docker environment, we often encounter some headaches...

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

JavaScript is the cornerstone of modern web development, and its main functions include event-driven programming, dynamic content generation and asynchronous programming. 1) Event-driven programming allows web pages to change dynamically according to user operations. 2) Dynamic content generation allows page content to be adjusted according to conditions. 3) Asynchronous programming ensures that the user interface is not blocked. JavaScript is widely used in web interaction, single-page application and server-side development, greatly improving the flexibility of user experience and cross-platform development.

Running multiple PHP versions simultaneously in the same system is a common requirement, especially when different projects depend on different versions of PHP. How to be on the same...

In PHP, you can effectively prevent CSRF attacks by using unpredictable tokens. Specific methods include: 1. Generate and embed CSRF tokens in the form; 2. Verify the validity of the token when processing the request.
