search
HomeBackend DevelopmentPHP Tutorial[Translation]PHP millennium bug (y2k compliance), _PHP tutorial

[Translation] PHP millennium bug (y2k compliance),

The clock is inexorably approaching the last year of 2000, and Sayers predicted unprecedented doom for the next year. Computer glitches occur in every conceivable area. Often referred to as the Year 2000 problem, or the Y2K bug, this situation is easily explained. The procedure explains that the XX act begins on Form XX date 19th in 2000 and thereafter for the following year. If your birthday is "2/2/05", will you be 101 years old in 101 years, or one year?

Cost estimates for fixing this bug run into the billions of dollars, at least that much money that could threaten a recurrence of protracted legal fees due to real and alleged damages. As a result of these devastating cost projections, there is increasing pressure on businesses and governments to use secure, legally binding statements that all software is guaranteed to be Year 2000 compliant.

As you may guess, this pressure often stems from lawyer-wary insurance companies, which are quite afraid of death-by-litigation, even more than the actual cost impact they may have, resulting in losses. To defend themselves against legal risks, organizations around the world rush to safety, in all possible haste, to certify that software such as this is Year 2000 compliant. They intend to wield some kind of legal protection when the inevitable chaos strikes, righteously declare themselves free of Y2K contamination and redirect lawsuits against the signatories of said document.

Remember this: If someone asks you to guarantee that your 2000 software is defect free, they are just looking for an excuse to sue you if they misuse your software, even if it should happen to be their own fault. Perhaps they have forgotten the terms of their software license, which may read closer to the following:

Neither the author nor the distributor shall be liable to any party for direct, indirect, special, incidental, or consequential damages arising out of the use of this software, documentation, or any derivatives thereof, even if the author advises of the possibility of such damages.

The author and distributor specifically disclaim all warranties, including but not limited to the implied warranties of merchantability, fitness for a particular purpose and non-infringement. This software is provided on an "as is" basis and the author and distributor have no obligation to provide maintenance, support, updates, improvements, or modifications.

Have you ever stopped to wonder just how long an automaker could survive such government scrutiny as an anti-warranty? Why are software makers any different? Somehow, though, they seem to be. Whether something like this will survive the litigational madness in the courts that is sure to ensue in the years to come remains to be seen. Don't expect anything.

About Y2K Anxiety has reached an increasingly fever pitch in most large organizations. Every few days, you see something else in the popular media predicting a certain amount of disruption. Nearly all of these reports are peppered with vague prevarications or technical confusion. That's not to say that there isn't a real problem here, and we can pretend nothing bothers us. The answer is of course yes. But what the problem stems from and what can be done about it are, at best, often misunderstood. Usually three repeated lies aggravate the situation.

Three lies about the Y2K epidemic

The first lie usually told is that the Y2K problem historically came from the memory of expensive computers last year so dear, that programmers maintained the date in a two-digit format to control the cost.

This statement is obviously wrong. Think about it. How much does a two-digit number need to be stored? Two bytes, 16 bits? No, let alone: ​​numeric data is rarely stored in text format because a more compact representation is readily available. A two-digit year will be a number ranging from 00 to 99. Can be represented in as little as 7 places.

How about using the full year, 1985 or 2010? The numbers would probably be represented in 11 digits. Are those veteran programmers really gleefully grabbing the speed savings of 4 whole bits/date? Surely precious hardware might be spared 4 bits! Even if not, one can use an offset from a reasonable base. If only the last two digits were used, the year date might represent not the absolute value, but the number of years since 1900. If so, this would still fit those mentioned 7-bits, at least for a while. Adding another point brings us clear to 2156. Ending question. Saving memory is not why this is done.

Although day users can choose non-expandable representation of the year, with the year as %1900 instead of 1900, this does not make it a hardware cost issue. It's still a short-sighted, soft design mistake.

The second lie is that this phenomenon is brand new. In the year 2000, countless systems will suddenly fail. This kind of thing has never happened before. Think about the ancient old man who was born in 1895. A program that reads their birthday as "95" will not pay them a few months to check since 1998, when they appear to be only three years old. The year 2000 did not happen in this equation. The so-called "year-2000" problem is not fashionable, nor is it limited to that year. Then it will be more obvious.

The third, and by far the most serious, lie about the Y2K problem, is that your company can protect itself from harm, whether true or not, by acquiring a compliance affidavit, or litigation. It can't. This belief in legal documents is actually hollow and dangerous. The wisest thing to do is to correct your deception immediately.

Insidious, the underlying root cause of the entire problem is either hardware or software. No, that's too easy, we know how to fix it. Apply for a few hundred dollars and lo and behold, everything is taken care of.

Unfortunately, that’s not it. The real problem is the wetware. That's right: the flaw lies not in our computers, nor in their programming, but in ourselves.

Most of the time, when people think of a date, they only use the last two digits. They write it on the check. They wrote it in the family Bible. Anytime you hear someone say, "I remember as far back as '65," or "'98, when the foundations of their collective consciousness were shaken by America's staggering failure in the Caribbean," you should know what they mean. Is this just 65? Speaker assumes life, it could be 1965 Is it just 98? Why, it's not that year, but back in 1898, when Spain lost what was left of its shabby empire to the upstart new worlders. In both cases, you can infer ambiguity from context, but if you don't have context, then you can only guess. And "Notorious".

The scariest part is that even if it is completely accurate and the computer program works and is obviously "Y2K compatible", you are still in big trouble. Take, for example, the famous Unix Carl program. Let's look at the current month.

  $ cal 2 98
		 February 98
	    Su Mo Tu We Th Fr Sa 
			 1  2  3
	     4  5  6  7  8  9 10
	    11 12 13 14 15 16 17
	    18 19 20 21 22 23 24
	    25 26 27 28
<br />等一等。那是什么?不是情人节应该是星期六,不是星期三,今年?哎呀,错了年!你真正要的类型是:
 $ cal 2 1998
		February 1998
	    Su Mo Tu We Th Fr Sa 
	     1  2  3  4  5  6  7
	     8  9 10 11 12 13 14
	    15 16 17 18 19 20 21
	    22 23 24 25 26 27 28
As you can see, no matter whether the programs are compatible or not, because humans use them they are not! Fixing the programs is certainly a necessary step, but it is far from sufficient. You can prove every program exists and it's still not secure enough. Until the time comes when billions of people in the world - or even just the millions using computers - are equally authenticated and guaranteed not to be forgotten, there will be no security. This won't happen.

Seeking a legally binding statement that a particular program cannot be abused intentionally or unintentionally is nothing more than a witch hunt and is doomed to fail in its ultimate goal of protecting you and yours. You can't help, there will always be cluefully-challenged users and programmers, even clueless people who occasionally have memory loss. You can't find them, you can't blame tools or language, you can't protect yourself. Every time one thinks about a year in double digit terms, the problem arises again. And no one figured out how to solve the software problem.

Perl

What about Perl? Is Perl 2000 "compatible"? The answer is, Perl is as Y2K compatible as your Pencil, no more, no less. What about comforting you? This is not what it should be. Just like you could commit a Y2K bug with your Pencil, you could do it with Perl - or with any other tool, for that matter. And you really don't need to travel far to do it; witness the perfect compatibility Carl's demonstration projects offer.

The date and time functions provided by Perl are the gmtime() and localtime() functions, which are derived from their C programming language. These supply ample information to determine well beyond the year 2000. A crisis in 2038, only for us to still be stuck on 32-bit machines, is somewhat unlikely although admittedly not entirely unthinkable.

These functions return the year (in a list context), contrary to popular misconception, and are not defined as a two-digit number. On the contrary, it is just the way it is now. What it actually is, is the present minus nineteen hundred years. This happened for many years between 1900 and 1999 with decimal numbers, but this wouldn't last long. In order to avoid the year 2000 problem, the year is not regarded as a number at all. Easy to say, easy to break. Let's say you want to find out what this year seems to be within the last 5 years, so you write the code like this.

<tt>   use Time::localtime;
    $then = time() + ( 60 * 60 * 24 * 365 * 5 );  # 5 years from now
    $that_year = localtime($then) -> year;

    printf("It shall be 19%d\n", $that_year);		# WRONG! 19103
    printf("It shall be %d\n", 1900 + $that_year);	# right:  2003<br /><br />如你所见,在坏人手中,甚至一个名义上的2000年兼容的工具如Perl或卡尔underclued或者仅仅是可以被滥用的健忘。<br /></tt>
Perl has no warranty and TPI does not support Perl. Furthermore, Perl is a language, and languages ​​can be abused in many ways. But that's the responsibility of the programmers and users, not the many creators of Perl. However, as Perl spokes-organization of the free software movement, we feel it necessary to point out that Perl is based on the same Y2K-compatible C language interface, and the Perl compiler and interpreter are written themselves. The Perl interface that accesses date information, when used as a design, is Y2K compatible in every sense of the word.

If it makes your lawyer or manager happy, do them a favor. You still have a lot to worry about.

<tt> </tt>
Original text: http://www.perl.com/pub/1999/01/y2k.html

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/852740.htmlTechArticle[Translation] PHP millennium bug (y2k compliance), the clock is relentlessly approaching the last year of 2000, The following year Doom Sayers predicted unprecedented computer failures in every conceivable...
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
The Continued Use of PHP: Reasons for Its EnduranceThe Continued Use of PHP: Reasons for Its EnduranceApr 19, 2025 am 12:23 AM

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python: Exploring Their Similarities and DifferencesPHP and Python: Exploring Their Similarities and DifferencesApr 19, 2025 am 12:21 AM

PHP and Python are both high-level programming languages ​​that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP and Python: Different Paradigms ExplainedPHP and Python: Different Paradigms ExplainedApr 18, 2025 am 12:26 AM

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP and Python: A Deep Dive into Their HistoryPHP and Python: A Deep Dive into Their HistoryApr 18, 2025 am 12:25 AM

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

Choosing Between PHP and Python: A GuideChoosing Between PHP and Python: A GuideApr 18, 2025 am 12:24 AM

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP and Frameworks: Modernizing the LanguagePHP and Frameworks: Modernizing the LanguageApr 18, 2025 am 12:14 AM

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHP's Impact: Web Development and BeyondPHP's Impact: Web Development and BeyondApr 18, 2025 am 12:10 AM

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

How does PHP type hinting work, including scalar types, return types, union types, and nullable types?How does PHP type hinting work, including scalar types, return types, union types, and nullable types?Apr 17, 2025 am 12:25 AM

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values ​​and handle functions that may return null values.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool