Ternary Expression Logic Primer Tutorial

Ternary Expression Logic Primer Tutorial

Ternary Expression Logic Primer Tutorial

Yesterday, we wonder if you examined Audio and Video Creator via Media Browsing Multiple Forms Tutorial‘s …


the changed

… code differences content? If you did, there were unusual “ternary expressions” used in that PHP code. Unusual for us, writing PHP, but not for Javascript, we can assure you. The ternary expression we always gravitate towards goes …


([ternary expression] ? [true content] : [false content])

… and you’ll know if you are a regular at this blog that we often parse web address URL “GET” arguments that “ternary expression” way in single lines of Javascript code such as …


var getcountries=location.search.split('countries=')[1] ? decodeURIComponent(location.search.split('countries=')[1].split('&')[0]).replace(/\+/g,' ') : '';

We wonder, though, writing PHP (serverside) code how we have not used “ternary expression” to good effect, up until now, in tandem with (the ever useful) isset PHP function we use to check for the existence of “GET” and “POST” web address URL arguments as per …

<?php

$varmodes="";
$justfa="<form method=GET action=./tutorial_to_animated_gif.php style=display:inline-block;><input name=allowaudio value=y type=hidden></input><input type=submit value=Audio></input></form>";
$justfav="<form method=GET action=./tutorial_to_animated_gif.php style=display:inline-block;><input name=allowaudio value=y type=hidden></input><input name=allowvideo value=y type=hidden></input><input title='Both, in addition to Images, always' type=submit value='/'></input></form>";
$justfv="<form method=GET action=./tutorial_to_animated_gif.php style=display:inline-block;><input name=allowvideo value=y type=hidden></input><input type=submit value=Video></input></form>";
// ... and then, later ...
$preextras="";
$ala="false";
$alv="false";
if (isset($_GET['allowaudio'])) {
$preextras.="<input onclick=\"usualclick=1;\" style=\"display:none;\" name=allowaudio id=\"mysa\" type=\"submit\" title='Tutorial Slideshow to Audio' value='Tutorial Slideshow to Audio'></input><div id=resultav style=display:none;></div>";
$ala="true";
$seventypc="60%";
$justfa=str_replace(" na" . (isset($_GET['allowvideo']) ? "OOPS" : "") . "me="," data-name=",str_replace("submit","SUBMIT style='border:1px solid yellow;' ",$justfa));
}
if (isset($_GET['allowvideo'])) {
$preextras.="<input onclick=\"usualclick=1;\" style=\"display:none;\" name=allowvideo id=\"mysv\" type=\"submit\" title='Tutorial Slideshow to Video' value='Tutorial Slideshow to Video'></input><div id=resultav style=display:none;></div>";
$alv="true";
$seventypc="60%";
$justfv=str_replace(" na" . (isset($_GET['allowaudio']) ? "OOPS" : "") . "me="," data-name=",str_replace("submit","SUBMIT style='border:1px solid yellow;' ",$justfv));
}
if (isset($_POST['allowaudio'])) {
$preextras.="<input onclick=\"usualclick=1;\" style=\"display:none;\" name=allowaudio id=\"mysa\" type=\"submit\" title='Tutorial Slideshow to Audio' value='Tutorial Slideshow to Audio'></input><div id=resultav style=display:none;></div>";
$ala="true";
$seventypc="60%";
$justfa=str_replace(" na" . (isset($_POST['allowvideo']) ? "OOPS" : "") . "me="," data-name=",str_replace("submit","SUBMIT style='border:1px solid yellow;' ",$justfa));
}
if (isset($_POST['allowvideo'])) {
$preextras.="<input onclick=\"usualclick=1;\" style=\"display:none;\" name=allowvideo id=\"mysv\" type=\"submit\" title='Tutorial Slideshow to Video' value='Tutorial Slideshow to Video'></input><div id=resultav style=display:none;></div>";
$alv="true";
$seventypc="60%";
$justfv=str_replace(" na" . (isset($_POST['allowaudio']) ? "OOPS" : "") . "me="," data-name=",str_replace("submit","SUBMIT style='border:1px solid yellow;' ",$justfv));
}
if ((isset($_POST['allowaudio']) && isset($_POST['allowvideo'])) || (isset($_GET['allowaudio']) && isset($_GET['allowvideo']))) {
$justfav="<form method=GET action=./tutorial_to_animated_gif.php style=display:inline-block;><input title='Neither, but Images, always' type=submit value='-'></input></form>";
}
$varmodes=" <table style=display:inline-block;><tr><td>" . $justfa . "</td><td>" . $justfav . "</td><td>" . $justfv . "</td></tr></table>";

?>

? But we have now … ngarrrrrrgggghhh!

If this was interesting you may be interested in this too.

This entry was posted in eLearning, Software, Tutorials and tagged , , , , , , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *