note 48056 added to function.isset
| From: | pianistsk8er at gmail dot com | Date: | Fri, 10 Dec 2004 02:23:14 +0000 |
| Subject: | note 48056 added to function.isset | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-81623@lists.php.net to get a copy of this message | ||
This function is very useful while calling to the URL to specify which template to be used on
certain parts of your application.
Here is an example...
<?php
$cat = $_GET['c'];
$id = $_GET['id'];
$error = 'templates/error.tpl';
if( isset($cat))
{
if( isset($id))
{
$var = 'templates/pics/' . $cat . '-' . $id . '.tpl';
if (is_file($var))
{
include($var);
}
else
{
include($error);
}
}
else
{
$var = 'templates/pics/' . $cat . '.tpl';
if (is_file($var))
{
include($var);
}
else
{
include($error);
}
}
}
else
{
include('templates/alternative.'.tpl);
}
?>
You can see several uses of the isset function being used to specify wheter a template is to be
called upon or not. This can easily prevent other generic PHP errors.
----
Manual Page -- http://www.php.net/manual/en/function.isset.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+48056
Delete -- http://master.php.net/manage/user-notes.php?action=delete+48056&report=yes
Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+48056&report=yes&reason=bad+code
Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+48056&report=yes&reason=spam
Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+48056&report=yes&reason=useless+example
Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+48056&report=yes&reason=contains+commercial+links
Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+48056&report=yes&reason=useless+note
Reject -- http://master.php.net/manage/user-notes.php?action=reject+48056&report=yes
Search -- http://master.php.net/manage/user-notes.php