GetValue() for form/url nvp and cookies with PHP
When dealing with PHP and you have Webspeed experience (https://progress.com), it might be useful to create a GetValue() function. It combines some things you are familiar with, such as the No-op value "?", accessing a cookie, or accessing a name-value pair - with a function you are familiar with! If your not familiar with webspeed, it is one thing to learn instead of the global variables.
A quick example follows:
<?php
function cout($a) {
? print($a . "<br>");
}
// Obtain a cookie first, then an form, then an
// url
function GetValue ($Name) {
?
? if(isset($_COOKIE[$Name]))
return $_COOKIE[$Name];
?
? if(isset($_REQUEST[$Name])) {
??? return $_REQUEST[$Name];
? } else {
??? return "?"; // unknown value
? }
}
?>
<html>
<head>
<?php setcookie("Test", "the cookie") ?>
</head>
<body>
<?php
cout(GetValue("a"));
cout(GetValue("Test"));
cout(GetValue("na"));
?>
<form>
A<input type="text" name="a"><br>
<input type="submit">
</form>
</body>
</html>