php - How to throw an exception but include parameters as part of the message? -


what best way this:

$params = array ('a' => 'b', 'c' => 'd'); // etc etc  throw new exception(    "could not because params << insert parameters >> bad",       $code  ); 

what best way include parameters part of exception , if must go in message, best way transform text no details lost?

keep in mind, want see this:

"could not because params: = b, c = d bad",   

you can use sprintf function

throw new exception(    sprintf("could not because params %s, %s bad", 'b', 'd'),       $code  ); 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -