I'm rusty in ColdFusion, I'm used to PHP for so long. I want to do something like this:
<?php $id = (isset($_GET['id'])) ? (int)$_GET['id'] : 0; ?>
Basically, check the url parameter called id , and if it exists, make sure it is an integer, so I can safely use it in database queries. If it ends with zero, that's good too.
I have:
<cfscript> if (IsDefined("URL.id") AND IsNumeric(URL.id)) { id = int(URL.id); } else { id = 0; } </cfscript>
It works, but it's terribly dirty. Is there a better way to do this?
source share