Home > Article > Technology peripherals > Google loses ground! ChatGPT is accurate and fast. No search is needed to fix bugs.
The last wave of image generation model fires made artists very anxious, and they began to jointly protest against models such as Stable Diffusion for infringing on their copyrights. However, this text revolution brought about by ChatGPT has made people in all walks of life A sense of crisis.
##Especially the programmer group was trembling even more, My job is gone, and I can only be reduced to "code review specialist" in the future.
But is ChatGPT’s ability to change codes really as strong as imagined?
Maybe it’s really that strong!
Using ChatGPT, There is no need to search for a valuable answer from a vast sea of documents. You only need to ask a question and you can directly return the answer. Chance is the right answer, and there are many examples, ranging from dependency library version updates to MacOS technical support.
ChatGPT takes action, one can beat two, the boss directly says save money...
Understand the version update of programming language"Version matching" is definitely the problem that causes programmers to lose their hair. Every time they encounter problems such as tensorflow incompatibility, mutual exclusion of various dependent library versions, language version characteristics, etc., a lot of energy is spent on debugging and modification.
Most people don’t pay attention to the content changes in each version update, but ChatGPT notes them all.
For example, if your boss gives you a requirement to migrate all websites from the very outdated PHP 7.4 version to the latest PHP 8, this problem may cause a headache.
PHP is the network programming language that WordPress and many other network management tools rely on, which involves a large number of plug-ins, some of which are not compatible with PHP 8. If you want your upgraded website to run successfully, the code within it must be found and fixed.
The general solution process is to first search for the problem on PHP.net, and then find some related comments on StackExchange to determine how to modify it. The whole process is very confusing. And time consuming.
Now you can enter the details of the problem directly into ChatGPT to quickly get a solution, and the answer will also include some demo code.
Q: When I was using PHP, the extract function returned a fatal error without passing in an array. The code ran normally in PHP 7.4. But there is a bug in PHP 8. Are there any changes to extract in PHP 8?
I'm having trouble with the PHP extract function giving a fatal error when not passed an array. In PHP 7.4, I did not get the error, but I seem to in PHP 8. Did extract change for PHP 8?
ChatGPT answer:In PHP8, the behavior of extract() function becomes more strict. In previous PHP versions, the extract () function would simply return false if no array was passed in; but in PHP 8, if no array was passed in, a fatal error would be thrown. This modification is to improve the robustness of the function and prevent potential errors caused by unexpected input.
You can check if the variable passed to the function is an array by using the is_array() function before calling extract ()
You can also use the array_key_exists() function to check whether the variable passed in is an array.
Or use the ... operator to destructure the array into multiple variables.
It turns out that according to ChatGPT’s answers, the bug can be fixed in a few minutes, and a large part of the reason is knowing Where to find the answer, and ChatGPT also explains how the behavior of functions changes in different versions of PHP.
Q: What PHP functions may cause problems when migrating code from PHP 7.4 to PHP 8?
What PHP functions are likely to break when moving from PHP 7.4 to PHP 8?
ChatGPT Answer:When migrating from PHP 7.4 to PHP 8, there are some functions and features that may not run or have different behavior. Here are some of the main changes that may cause problems:
These are just some examples of changes that may cause problems when migrating from PHP 7.4 to PHP 8. It is a good idea to test your code and application thoroughly before upgrading to ensure that everything works as expected. run.
In this answer, ChatGPT also said "as mentioned in the previous answer", which made people feel both surprised and scared.
In the code being modified, the original developer (who has left his job for a long time) often uses create_function. I didn't know that the function had been deprecated at the time, but according to With the modification list provided by ChatGPT, just search the code to find what needs to be updated and rewritten.
Then, go ahead and ask ChatGPT to show you how to replace the function.
Q: What is a good way to rewrite code using create_function in PHP? Give me an example of using create_function.
##What's a good way to rewrite code using create_function in PHP? Can you give me an example using create_function, and then one using the currently proper mechanism?create_function is a deprecated function in PHP that is used to create anonymous functions. This function is no longer officially recommended and has been removed in PHP 8.0. It is now possible to create anonymous functions (also known as closures) using the function keyword.
The following is an example:
The following is using an anonymous function Equivalent code:
In addition, you can also use the use keyword to pass variables into the closure:
This The answer is quite clear, and you can quickly rewrite the code after reading the explanation.
Suppose you have some questions when studying Optimize Storage (Optimize Storage) on Mac. In order to narrow the scope of research, you can ask ChatGPT directly.
Q: When using the MacOS feature Optimize Mac Storage, will Time Machine make an incomplete backup because some files are only represented as stubs on the local machine?
If you use the MacOS feature Optimize Mac Storage, will Time Machine make incomplete backups because some files are only represented as stubs on the local machine?
When setting up Time Machine for backup, all files, including those that have been uninstalled using Optimize Mac Storage, will be backed up, but the original files will be replaced with stub files. .
This also means that if you are restoring your Mac from a Time Machine backup and the "Optimize Mac Storage" feature is enabled, any uninstalled files will not be included During recovery, you need to download from iCloud again.
It is worth noting that if you uninstall a large number of files, the Time Machine backup may take up more space than using Optimized Mac Storage because the backup stub file takes up less space.
In short, if you use the "Optimize Mac Storage" feature, Time Machine will make an incomplete backup because it will only back up the stub files, not the ones that have been uninstalled. Original files in the cloud.
ChatGPT’s answer above is correct.
ChatGPT can indeed save time required for development and bug resolution.
Normally, programmers need to constantly debug when writing code, and also conduct a lot of Internet searches to find clues from search results, including reading discussions and comments.
Of course, the entire search process can provide a lot of information, definitely more information than you can get from a chatbot, and you can also see many hidden tricks in the comment area.
But when you need to be in a hurry or before a critical deadline, Searching in large quantities is definitely a stupid way, and using ChatGPT to solve programming problems has proven to be Very effective.
ChatGPT is like other models, you have to realize that the AI’s answer is not always correct, you will most likely get a completely wrong answer, but it is indeed a very good one tool.
However, Where did ChatGPT get this information? Has anyone ever written an article specifically about extract or create_function? Is someone's knowledge used as raw material for answer generation?
Judging from the current situation, at least for Google authors, there was an opportunity for search engines to provide traffic for articles in return for sharing information, but things like ChatGPT Chatbots directly monopolize information acquisition channels, and of course users gain higher productivity. Will anyone lose the sense of fulfillment at work?
Q: When you answer a question, have you accepted the knowledge contributed by others, and have you obtained the work results from the original human resources?
ChatGPT, when you answer a question, are you taking knowledge others have contributed and are you taking work and credit away from the original human sources?
ChatGPT's answer: As an artificial intelligence language model created by OpenAI, I have no personal opinions or thoughts. But I can tell you that the information used to generate the responses is based on the data I was trained on, which includes huge amounts of text from the Internet.
This text was written by many different people and sources, and I do not have the ability to attribute the information I have provided to specific individuals. My goal is to provide useful and accurate information to help users find the answers they are looking for.It’s important to remember that my answers are generated based on patterns in the data I was trained on and may not always be completely accurate or up-to-date.
The above is the detailed content of Google loses ground! ChatGPT is accurate and fast. No search is needed to fix bugs.. For more information, please follow other related articles on the PHP Chinese website!