Html auto writes =”” after an attribute with php

Well, I’ve been trying to put a “required” attribute in an html text input with php but I can`t.
I’ve a php function that creates automatically a form with all the data you give to it, but that is not the problem.
The problem is that I’ve a boolean parameter in which you choose if some of the inputs are required or not, and when one of them is true, the input must have the “required” attribute on it.
Something like…

function make_form(..., $required,...) {
   ...
   echo "<input type='...' name='...' value='...' ".($required?"required":"").">";
   ...
}

What I want is that when the $required variable is true, the input has “required” on it, but instead, this is what the server sends to the client:

<input type='...' name='...' value='...' required="">

And I don’t want those =”” after the “required” cause then it doesn’t validate that the input is not empty.
I want this:

<input type'...' name='...' value='...' required>

Without the =””

I’ve tried using htmlentities(“required”), htmlspecialchars(“required”), adding an &nbsp after the “required”, using print instead of echo, using a variable instead of plain text, changing the position of the “required” inside the tag, etc. and the =”” still appears.
I hope you can help me; I’m using php 8.
Thank you very much.