note 127174 added to function.compact

From: Date: Sat, 11 Jun 2022 02:30:48 +0000
Subject: note 127174 added to function.compact
Groups: php.notes 
Request: Send a blank email to php-notes+get-218586@lists.php.net to get a copy of this message
compact() is particularly useful with PDO and prepared requests : <?php $sql = 'SELECT ALL * FROM users WHERE first_name = :first_name AND last_name = :last_name'; $select = $pdo->prepare($sql); $first_name = 'John'; $last_name = 'Doe'; $select->execute(compact('first_name', 'last_name')); // Instead of : $select->execute([ 'first_name' => $first_name, 'last_name' => $last_name, ]); ---- Server IP: 45.112.84.4 Probable Submitter: 80.90.12.131 (proxied: 2a01:e0a:968:1840:a589:2b30:4249:ed57) ---- Manual Page -- https://php.net/manual/en/function.compact.php Edit -- https://main.php.net/note/edit/127174 Del: integrated -- https://main.php.net/note/delete/127174/integrated Del: useless -- https://main.php.net/note/delete/127174/useless Del: bad code -- https://main.php.net/note/delete/127174/bad+code Del: spam -- https://main.php.net/note/delete/127174/spam Del: non-english -- https://main.php.net/note/delete/127174/non-english Del: in docs -- https://main.php.net/note/delete/127174/in+docs Del: other reasons-- https://main.php.net/note/delete/127174 Reject -- https://main.php.net/note/reject/127174 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#218586) next »