Forums | Mahara Community
Developers
/
GET ID
02 July 2019, 3:26
Hello,
I have a small question. Is there a easy way to get the id from the url?
I think the normal $ _GET ['id'] is blocked ...
Is this function?
$groupid = param_integer('id');
Thank you!
02 July 2019, 11:35
Hi
Yes if you are wanting to get an integer value from the url you can use:
$id = param_integer('id');
if you are wanting the page to load both in instances with or without an id supplied
$id = param_integer('id', null);
if you are wanting the page to load both in instances with or without an id supplied but want to default to a specific value, eg '27'
$id = param_integer('id', 27);
There are similar options for a string
param_alpha() -- for alpha strings only
param_alphanum() -- for alpha stings and numbers
param_alphanumext() -- for alpha strings / numbers / underscore / dot / dash
param_variable() -- no checking done so not recommended to use
(only use if you can't control the info coming from 3rd party application)
see htdocs/lib/web.php for more info
Cheers
Robert
02 July 2019, 22:22
Thanks for this useful informations!
Now everything is clearer, thank you!!
Antonella