Detailed explanation of the goto statement added in PHP5.3
In "go" straight out of ASM or any other assembly language. Here's a link: I'd like to know: what can I do to make my code more efficient and how can I work on this larger project without snapping it up. Since goto statements allow you to jump back and forth and accidentally wait in an infinite loop if something happens the wrong way. Can you give me an example of this? EDIT: Well, I've seen the responses on CodeGo.net, and apparently there is widespread concern about "GOTO" and that it is bad. So I've been wondering: why is PHP's troublesome adding it to the language. If they don't see it inside, they won't do it...why? Also: A general comment about "go to" here in the StackOverflow EDIT2: Seeing as this question caused a lot of bad things it made me sad to go and ask my dad about the jump. He is 52 years old and an engineer. He did a good amount of programming in FORTRAN and COBOL during his days, mostly in FORTRAN and COBOL. Now he does IT services, servers and the like. Anyway, he said those things about "back in my day..." After a moment after that, he went back to saying that even back in his days as a student, they were shocked to know that this wasn't A clever idea, but they had no better idea of the situation. TRY/CATCH is still a few years old and Error handling is almost existed. So what are your procedures for checking that you did? Add a few lines at the end that give you the printout and everything you need to check your code, and then you put the lines: "go to print;", or similar, to start the printing of your data. And in this way, you slowly debug your code. He agrees that going into the modern programming world what he finds reasonable is an "emergency interrupt" in debugging and unexpected situations. Sort of like goto fatal_error; and does something for the "is fatal_error" part of your code, showing you the in-depth results. But only if you create the final product there should be no jumps - Late edit: Another way to go about "go" in PHP5.3/PHP6
1. If you are writing good PHP Code , you should not need to jump. I think it's a bug they're adding it in because it just leads to lazy programming. See for a good one on adding this to PHP, and here's Stack Overflow,
2. I've only found out about goto: typing out nested loops. But most new languages have to do this without goto anyway (break
3. Is there such a thing as a jump. Maybe, just maybe, it's possible to get out of multiple nested loops, but you can already do "break 2" like this. Tags in Java also serve this purpose better than go. Maybe it's an exception with code writing when you need to jump to the end of a bunch at a time where one of them fails. But that just fixes crappy code to even crappier code.
4. It can be used for debugging purposes so you don't have to break out or refactor blocks of code just to temporarily change the worker threads.
5. In classic VB coding, using goto is very convenient for simulating try/catch error handling like this:
Function MyFunction() as String '-- start of error block ' On Error Goto Catch ' do something here that might cause an error MyFunction = "IT WORKED" Exit Function Catch: ' error occured - do something else MyFunction = Err.Description ' '-- end of error block End Function ...这里是一种模拟的try / catch /终于..Function MyFunction() as String '-- start of error block ' On Error Goto Catch ' do something here that might cause an error MyFunction = "IT WORKED" Goto Finally Catch: ' error occured - do something else MyFunction = Err.Description Err.Clear Finally: ' put your finally code here ' '-- end of error block End Function
It can also be used to clear at the end of a function, although I Thinking you could make another function that could be called to do this in case of cleanup. To be honest, I had never been in PHP and I thought to myself: "Well, I wish there could be a goto. I didn't read up on why they decided to do this, but, those guys are very smart and had the opportunity to consider PHP Very good direction so far, so maybe there's a need for that, we don't know yet.
6. The thing I see about using goto is the cross-language port I wrote in C. The language 's parser Generator generates a parser with goto statements (it's easier to use goto than more sane control structures), and porting it to PHP is now less of a headache ##. #7. When writing finite state machines, you do need one of them when the parsing context is released, although we can live without a jump if
continue $case; is in a switch block. Efficiently jumping to a different situation and closing the scope is achievable in as many languages as there are nowadays. Until then, we were pretty much stuck with goto 8. Jumps can help reduce code duplication in stack unwinding. Pseudocode below:
do A if (error) goto out_a; do B if (error) goto out_b; do C if (error) goto out_c; goto out; out_c: undo C out_b: undo B: out_a: undo A out: return ret;
(伪由罗伯特爱,从linux内核归档的邮件列表采取代码:)
9. 由于之前已经说过,GOTO是唯一真正需要的类型的算法,通常是那些在语言解析或有限状态机。我从来没有错过在PHP缺乏goto语句。 OTOH,我有一个语言,其中只有两个结构是函数和条件goto方法:SNOBOL4。由于意大利面条代码的风险是如此之高,最SNOBOL4是/很小心的避免这一点。但是goto语句也使很紧的编程,创意循环执行等。它实际上是更容易做到的FSM型圈,如果你有在使用goto。
10. 我承认我转到我的代码。 :) 唯一的理由似乎有利于在最短的flyway从其他语言到PHP(实际上只改变语言不碰控制结构)和重构代码的移植的第2阶段。 我个人认为和同事,因为他们可以避开有条件决裂-S的循环,他们将能够抵御转到诱惑。
11. 生成的代码可以使goto语句,我猜。对生成的代码的好处是,你并不需要去维护它-你只是重新生成它。
12. goto真正应该尽管这是在语言,并会进行过时由于更好的编程实践。现在添加它似乎是一个倒退的一步。
13. goto语句中的B大优势就是学习曲线。人们不禁要问,为什么像visualstudia和Mac电脑的工具做的很好。原因是,人们需要的不仅仅是一个伟大的产品,他们希望有一个 伟大的产品,他们可以在短短一个小时左右学习。现在很多 一个天只计划为他们的工作之一。我看到这么多的书说,一个人永远不能 使用goto语句,然后给五年左右的技术,例如,他们说每消除 需要它。我说,只是事实,5是该有多好转到证明 是!!我没有教的五件事,包括异常结构, 把整个章节来解释!!当你真正需要的是一个简单的跳转 可在30秒内进行解释。当然,你可以创建恶意代码与他们如果 希望---但是,嘿,最不想写糟糕的代码,如果他们 他们才可以呢。最goto语句在我们的实验室所做的代码简单 了解和学习;程度远远超过了读一本2000页的书。
The above is the detailed content of Detailed explanation of the goto statement added in PHP5.3. For more information, please follow other related articles on the PHP Chinese website!

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

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

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,

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

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.

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

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.
