From the course: Building PHP Applications with Generative AI

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Creating comments for code

Creating comments for code

- [Instructor] Inline comments are a bit more subjective than docblocks, but AI can help us nonetheless. Let's see what we can come up with. So I'm going to highlight the code here in the get_age function. Click on the star and say, "Can you generate some inline comments describing what this code does?" All right, so you can see it gets, like, a little strange here. And it's telling us (chuckles) the file path, which I don't think we really need. But then these comments are good, right? It tells us exactly what's happening here. If you click the refresh button, it'll try again. So it might take some attempts to get some good comments. This is a little bit better. So we'll try one more time. Create new DateTime objects, so this is okay. What I want to do here is remove this block because we basically have that already, right? And then it looks like it didn't replace our variables. It just added some extra variables. So your mileage may vary on these inline comments. Let's look at…

Contents