使用模具皱眉/不好吗?

I'm currently developping my first proper php website, and I find myself, especially when writing ajax/php pages, writing procedural codes which look like this:

//sanitize input
foo();

//handle request
bar();

//sends reply
echo json_encode( $result );

die;

function foo(){...}
function bar(){...}

where my code is clearly separated into a procedural step by step part at the top of the page, and a list of function at the end.

I like using die; in that context since it provides a clear cut between the two parts of the code, but I'm wondering if it is frowned upon for some reason.

Thank you in advance!

Yes, I would say explicitly terminating your PHP script like this is a bad idea. Certainly it is very unconventional and will likely confuse other programmers who may one day be maintaining your code.

There's no actual need to exit the script with die in the example you posted, since once the interpreter reaches that point it will pass harmlessly over the function definitions and the script will terminate normally at the end of the file, as anyone would expect. So what you're doing is unnecessary.

But it's also actively confusing: Because the script's exit point is now buried in the middle of the file, it will be easy for someone making a quick edit to add code below the die and waste time trying to figure out why their changes are having no effect. No programmer is going to assume the script is meant to up and die at some random point in its middle.

A professional programmer normally groups function definitions together towards the top of a file, ahead of the code that invokes them. This convention dates back to structured-programming languages like Pascal that actually enforced this as a rule, but it makes good sense in general. Think of how people communicate in everyday life: Isn't it confusing when a person starts talking about something before they've told you what it is they're talking about?