{"id":52543,"date":"2021-06-20T03:01:37","date_gmt":"2021-06-19T17:01:37","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=52543"},"modified":"2021-06-19T11:12:00","modified_gmt":"2021-06-19T01:12:00","slug":"ternary-expression-logic-primer-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/ternary-expression-logic-primer-tutorial\/","title":{"rendered":"Ternary Expression Logic Primer Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/animegif\/ternary_highlight.jpg\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"Ternary Expression Logic Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/animegif\/ternary_highlight.jpg\" title=\"Ternary Expression Logic Primer Tutorial\"  style=\"float:left;\" \/><\/a><p class=\"wp-caption-text\">Ternary Expression Logic Primer Tutorial<\/p><\/div>\n<p>Yesterday, we wonder if you examined <a target=_blank href='\/\/www.rjmprogramming.com.au\/ITblog\/audio-and-video-creator-via-media-browsing-multiple-forms-tutorial\/'>Audio and Video Creator via Media Browsing Multiple Forms Tutorial<\/a>&#8216;s &#8230;<\/p>\n<p><code><br \/>\n<a target=_blank title='tutorial_to_animated_gif.php' href='http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=HTTP:\/\/www.rjmprogramming.com.au\/PHP\/animegif\/tutorial_to_animated_gif.php-----------------------------GETME'>the changed<\/a><br \/>\n<\/code><\/p>\n<p> &#8230; code differences content?  If you did, there were unusual &#8220;ternary expressions&#8221; 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 &#8230;<\/p>\n<p><code><br \/>\n(<font color=blue>[ternary expression]<\/font> ? <font color=darkgreen>[true content]<\/font> : <font color=red>[false content]<\/font>)<br \/>\n<\/code><\/p>\n<p> &#8230; and you&#8217;ll know if you are a regular at this blog that we often parse web address URL &#8220;GET&#8221; arguments that &#8220;ternary expression&#8221; way in single lines of Javascript code such as &#8230;<\/p>\n<p><code><br \/>\nvar getcountries=<font color=blue>location.search.split('countries=')[1]<\/font> ? <font color=darkgreen>decodeURIComponent(location.search.split('countries=')[1].split('&')[0]).replace(\/\\+\/g,' ')<\/font> : <font color=red>''<\/font>;<br \/>\n<\/code><\/p>\n<p>We wonder, though, writing PHP (serverside) code how we have not used &#8220;ternary expression&#8221; to good effect, up until now, in tandem with (the ever useful) <a target=_blank title='PHP isset' href='https:\/\/www.php.net\/manual\/en\/function.isset.php'>isset<\/a> PHP function we use to check for the existence of &#8220;GET&#8221; and &#8220;POST&#8221; web address URL arguments as per &#8230;<\/p>\n<p>&lt;?php<br \/>\n<code><br \/>\n$varmodes=\"\";<br \/>\n$justfa=\"&lt;form method=GET action=.\/tutorial_to_animated_gif.php style=display:inline-block;&gt;&lt;input name=allowaudio value=y type=hidden&gt;&lt;\/input&gt;&lt;input type=submit value=Audio&gt;&lt;\/input&gt;&lt;\/form&gt;\";<br \/>\n$justfav=\"&lt;form method=GET action=.\/tutorial_to_animated_gif.php style=display:inline-block;&gt;&lt;input name=allowaudio value=y type=hidden&gt;&lt;\/input&gt;&lt;input name=allowvideo value=y type=hidden&gt;&lt;\/input&gt;&lt;input title='Both, in addition to Images, always' type=submit value='\/'&gt;&lt;\/input&gt;&lt;\/form&gt;\";<br \/>\n$justfv=\"&lt;form method=GET action=.\/tutorial_to_animated_gif.php style=display:inline-block;&gt;&lt;input name=allowvideo value=y type=hidden&gt;&lt;\/input&gt;&lt;input type=submit value=Video&gt;&lt;\/input&gt;&lt;\/form&gt;\";<br \/>\n \/\/ ... and then, later ...<br \/>\n   $preextras=\"\";<br \/>\n   $ala=\"false\";<br \/>\n   $alv=\"false\";<br \/>\nif (isset($_GET['allowaudio'])) {<br \/>\n $preextras.=\"&lt;input onclick=\\\"usualclick=1;\\\" style=\\\"display:none;\\\" name=allowaudio id=\\\"mysa\\\" type=\\\"submit\\\" title='Tutorial Slideshow to Audio' value='Tutorial Slideshow to Audio'&gt;&lt;\/input&gt;&lt;div id=resultav style=display:none;&gt;&lt;\/div&gt;\";<br \/>\n $ala=\"true\";<br \/>\n $seventypc=\"60%\";<br \/>\n $justfa=str_replace(\" na\" . (<font color=blue>isset($_GET['allowvideo'])<\/font> ? <font color=darkgreen>\"OOPS\"<\/font> : <font color=red>\"\"<\/font>) . \"me=\",\" data-name=\",str_replace(\"submit\",\"SUBMIT style='border:1px solid yellow;' \",$justfa));<br \/>\n}<br \/>\nif (isset($_GET['allowvideo'])) {<br \/>\n $preextras.=\"&lt;input onclick=\\\"usualclick=1;\\\" style=\\\"display:none;\\\" name=allowvideo id=\\\"mysv\\\" type=\\\"submit\\\" title='Tutorial Slideshow to Video' value='Tutorial Slideshow to Video'&gt;&lt;\/input&gt;&lt;div id=resultav style=display:none;&gt;&lt;\/div&gt;\";<br \/>\n $alv=\"true\";<br \/>\n $seventypc=\"60%\";<br \/>\n $justfv=str_replace(\" na\" . (<font color=blue>isset($_GET['allowaudio'])<\/font> ? <font color=darkgreen>\"OOPS\"<\/font> : <font color=red>\"\"<\/font>) . \"me=\",\" data-name=\",str_replace(\"submit\",\"SUBMIT style='border:1px solid yellow;' \",$justfv));<br \/>\n}<br \/>\nif (isset($_POST['allowaudio'])) {<br \/>\n $preextras.=\"&lt;input onclick=\\\"usualclick=1;\\\" style=\\\"display:none;\\\" name=allowaudio id=\\\"mysa\\\" type=\\\"submit\\\" title='Tutorial Slideshow to Audio' value='Tutorial Slideshow to Audio'&gt;&lt;\/input&gt;&lt;div id=resultav style=display:none;&gt;&lt;\/div&gt;\";<br \/>\n $ala=\"true\";<br \/>\n $seventypc=\"60%\";<br \/>\n $justfa=str_replace(\" na\" . (<font color=blue>isset($_POST['allowvideo'])<\/font> ? <font color=darkgreen>\"OOPS\"<\/font> : <font color=red>\"\"<\/font>) . \"me=\",\" data-name=\",str_replace(\"submit\",\"SUBMIT style='border:1px solid yellow;' \",$justfa));<br \/>\n}<br \/>\nif (isset($_POST['allowvideo'])) {<br \/>\n $preextras.=\"&lt;input onclick=\\\"usualclick=1;\\\" style=\\\"display:none;\\\" name=allowvideo id=\\\"mysv\\\" type=\\\"submit\\\" title='Tutorial Slideshow to Video' value='Tutorial Slideshow to Video'&gt;&lt;\/input&gt;&lt;div id=resultav style=display:none;&gt;&lt;\/div&gt;\";<br \/>\n $alv=\"true\";<br \/>\n $seventypc=\"60%\";<br \/>\n $justfv=str_replace(\" na\" . (<font color=blue>isset($_POST['allowaudio'])<\/font> ? <font color=darkgreen>\"OOPS\"<\/font> : <font color=red>\"\"<\/font>) . \"me=\",\" data-name=\",str_replace(\"submit\",\"SUBMIT style='border:1px solid yellow;' \",$justfv));<br \/>\n}<br \/>\nif ((isset($_POST['allowaudio']) && isset($_POST['allowvideo'])) || (isset($_GET['allowaudio']) && isset($_GET['allowvideo']))) {<br \/>\n$justfav=\"&lt;form method=GET action=.\/tutorial_to_animated_gif.php style=display:inline-block;&gt;&lt;input title='Neither, but Images, always' type=submit value='-'&gt;&lt;\/input&gt;&lt;\/form&gt;\";<br \/>\n}<br \/>\n$varmodes=\"&nbsp;&lt;table style=display:inline-block;&gt;&lt;tr&gt;&lt;td&gt;\" . $justfa . \"&lt;\/td&gt;&lt;td&gt;\" . $justfav . \"&lt;\/td&gt;&lt;td&gt;\" . $justfv . \"&lt;\/td&gt;&lt;\/tr&gt;&lt;\/table&gt;\";<br \/>\n<\/code><br \/>\n?&gt;<\/p>\n<p>?  But we have now &#8230; ngarrrrrrgggghhh!<\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d52543' onclick='var dv=document.getElementById(\"d52543\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/expression\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d52543' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Yesterday, we wonder if you examined Audio and Video Creator via Media Browsing Multiple Forms Tutorial&#8216;s &#8230; the changed &#8230; code differences content? If you did, there were unusual &#8220;ternary expressions&#8221; used in that PHP code. Unusual for us, writing &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/ternary-expression-logic-primer-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,33,37],"tags":[2914,2915,1835,2554,2147,1820,1533,3661,652,932,997,3404,3660,1319,1721],"class_list":["post-52543","post","type-post","status-publish","format-standard","hentry","category-elearning","category-software","category-tutorials","tag-_get","tag-_post","tag-arguments","tag-boolean","tag-delimiter","tag-expression","tag-get","tag-isset","tag-javascript","tag-php","tag-programming","tag-ternary","tag-ternary-expression","tag-tutorial","tag-variable"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/52543"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=52543"}],"version-history":[{"count":7,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/52543\/revisions"}],"predecessor-version":[{"id":52550,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/52543\/revisions\/52550"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=52543"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=52543"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=52543"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}