3v4l.org

run code in 300+ PHP versions simultaneously
<?php $where = array(); $_GET['CodigoUtente'] = 'sany'; $_GET['Nome'] = 'dddd'; if(isset($_GET['CodigoUtente'])){ $where[] = "CodigoUtente = '".$_GET['CodigoUtente']."'"; } if(isset($_GET['Nome'])){ $where[] = "Nome = '".$_GET['Nome']."'"; } $sql = "SELECT CodigoUtente, Nome, DataNasc, Sexo, Estadocivil, Nacionalidade, Responsavel, Parentesco, Contato FROM centrodb.PsicUtentes"; if(!empty($where)){ $final_where = count($where) > 1 ? implode(' OR ', $where) : end($where); $sql = "$sql WHERE ". $final_where; } echo $sql;
Output for 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.27, 8.4.1 - 8.4.14
SELECT CodigoUtente, Nome, DataNasc, Sexo, Estadocivil, Nacionalidade, Responsavel, Parentesco, Contato FROM centrodb.PsicUtentes WHERE CodigoUtente = 'sany' OR Nome = 'dddd'

preferences:
153.31 ms | 408 KiB | 5 Q