{"id":345,"date":"2023-12-04T07:24:38","date_gmt":"2023-12-04T06:24:38","guid":{"rendered":"https:\/\/gdm.sosthe.sk\/?page_id=345"},"modified":"2023-12-04T07:24:38","modified_gmt":"2023-12-04T06:24:38","slug":"operatory","status":"publish","type":"page","link":"https:\/\/gdm.sosthe.sk\/?page_id=345","title":{"rendered":"Oper\u00e1tory"},"content":{"rendered":"<h3>1. Aritmetick\u00e9 oper\u00e1tory<\/h3>\n<table>\n<thead>\n<tr>\n<td width=\"178\"><strong>Matematick\u00e1 oper\u00e1cia<\/strong><\/td>\n<td width=\"117\"><strong>Pr\u00edklad<\/strong><\/td>\n<td width=\"81\"><strong>V\u00fdsledok<\/strong><\/td>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td width=\"178\"><strong>s\u00fa\u010det<\/strong><\/td>\n<td width=\"117\">$cislo = 12+8<\/td>\n<td width=\"81\">20<\/td>\n<\/tr>\n<tr>\n<td width=\"178\"><strong>rozdiel<\/strong><\/td>\n<td width=\"117\">$cislo = 12-8<\/td>\n<td width=\"81\">4<\/td>\n<\/tr>\n<tr>\n<td width=\"178\"><strong>n\u00e1sobenie<\/strong><\/td>\n<td width=\"117\">$cislo = 12*8<\/td>\n<td width=\"81\">96<\/td>\n<\/tr>\n<tr>\n<td width=\"178\"><strong>delenie<\/strong><\/td>\n<td width=\"117\">$cislo = 12\/8<\/td>\n<td width=\"81\">1.5<\/td>\n<\/tr>\n<tr>\n<td width=\"178\"><strong>zvy\u0161ok po delen\u00ed<\/strong><\/td>\n<td width=\"117\">$cislo = 12%8<\/td>\n<td width=\"81\">4<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Priorita vykon\u00e1vania oper\u00e1ci\u00ed plat\u00ed ako v matematike. Teda n\u00e1sobenie a delenie s\u00fa vykon\u00e1van\u00e9 sk\u00f4r ako s\u010d\u00edtanie a od\u010d\u00edtanie. Ak chceme najsk\u00f4r s\u010d\u00edta\u0165, mus\u00edme pou\u017ei\u0165 z\u00e1tvorky.<\/p>\n<p>Ak m\u00e1me u\u017e deklarovan\u00fa premenn\u00fa a chceme k nej pri\u010d\u00edta\u0165 (od\u010d\u00edta\u0165, vyn\u00e1sobi\u0165, vydeli\u0165) nejak\u00e9 \u010d\u00edslo, m\u00f4\u017eeme vyu\u017ei\u0165 zjednodu\u0161en\u00e9ho z\u00e1pisu. Uva\u017eujme premenn\u00fa\u00a0<em>$var = 12<\/em>.<\/p>\n<table>\n<thead>\n<tr>\n<td width=\"178\"><strong>Matematick\u00e1 oper\u00e1cia<\/strong><\/td>\n<td width=\"117\"><strong>Pr\u00edklad<\/strong><\/td>\n<td width=\"81\"><strong>V\u00fdsledok<\/strong><\/td>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td width=\"178\"><strong>pri\u010d\u00edtanie<\/strong><\/td>\n<td width=\"117\">$var = $var+8<\/td>\n<td width=\"81\">20<\/td>\n<\/tr>\n<tr>\n<td width=\"178\"><strong>pri\u010d\u00edtanie<\/strong><\/td>\n<td width=\"117\">$var += 8<\/td>\n<td width=\"81\">20<\/td>\n<\/tr>\n<tr>\n<td width=\"178\"><strong>od\u010d\u00edtanie<\/strong><\/td>\n<td width=\"117\">$var -= 8<\/td>\n<td width=\"81\">4<\/td>\n<\/tr>\n<tr>\n<td width=\"178\"><strong>vyn\u00e1sobenie<\/strong><\/td>\n<td width=\"117\">$var *= 8<\/td>\n<td width=\"81\">96<\/td>\n<\/tr>\n<tr>\n<td width=\"178\"><strong>vydelenie<\/strong><\/td>\n<td width=\"117\">$var \/= 8<\/td>\n<td width=\"81\">1.5<\/td>\n<\/tr>\n<tr>\n<td width=\"178\"><strong>zvy\u0161ok po delen\u00ed<\/strong><\/td>\n<td width=\"117\">$var %= 8<\/td>\n<td width=\"81\">4<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Inkrement\u00e1cia (zv\u00fd\u0161enie), dekrement\u00e1cia (zn\u00ed\u017eenie). Uva\u017eujme premenn\u00fa\u00a0<em>$var = 12<\/em>.<\/p>\n<table>\n<thead>\n<tr>\n<td width=\"178\"><strong>Matematick\u00e1 oper\u00e1cia<\/strong><\/td>\n<td width=\"105\"><strong>Pr\u00edklad<\/strong><\/td>\n<td width=\"140\"><strong>V\u00fdsledok<\/strong><\/td>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td width=\"178\"><strong>o jednotku viac<\/strong><\/td>\n<td width=\"105\">$var++<\/td>\n<td width=\"140\">13<\/td>\n<\/tr>\n<tr>\n<td width=\"178\"><strong>o jednotku menej<\/strong><\/td>\n<td width=\"105\">$var\u2013<\/td>\n<td width=\"140\">11<\/td>\n<\/tr>\n<tr>\n<td width=\"178\"><\/td>\n<td width=\"105\">$y = $var++<\/td>\n<td width=\"140\">$y = 12, $var=13<\/td>\n<\/tr>\n<tr>\n<td width=\"178\"><\/td>\n<td width=\"105\">$y = $var\u2013<\/td>\n<td width=\"140\">$y = 12, $var=11<\/td>\n<\/tr>\n<tr>\n<td width=\"178\"><\/td>\n<td width=\"105\">$y = ++$var<\/td>\n<td width=\"140\">$y = 13, $var=13<\/td>\n<\/tr>\n<tr>\n<td width=\"178\"><\/td>\n<td width=\"105\">$y = \u2013$var<\/td>\n<td width=\"140\">$y = 11, $var=11<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><em>Pr\u00edklad:<\/em><\/p>\n<pre>echo \"Dnes je: \".Date(\"j. m. Y\");\r\n  echo \"Zajtra bude: \".Date (\"j. m. Y\",time()+86400); \/\/ 86400=24*60*60\r\n  echo \"Pr\u00e1ve je: \".Date (\"H:i:s \");\r\n  echo \"O hodinou bude: \".Date (\"H:i:s\",Time()+3600); \/\/ 3600=60*60\r\n<\/pre>\n<p><em>V\u00fdsledok pr\u00edkladu:<\/em><\/p>\n<p>Dnes je: 29. 11. 2012<br \/>\nZajtra bude: 30. 11. 2012<br \/>\nPr\u00e1ve je: 22:50:47<br \/>\nO hodinou bude: 23:50:47<strong><br \/>\n<\/strong><\/p>\n<h3><strong>2. Logick\u00e9 oper\u00e1tory<\/strong><\/h3>\n<p>Vracaj\u00fa len dva stavy:\u00a0<em>true<\/em>\u00a0alebo\u00a0<em>false<\/em>. Vyu\u017e\u00edvaj\u00fa sa napr\u00edklad pri cykloch alebo vetven\u00ed.<\/p>\n<table>\n<thead>\n<tr>\n<td width=\"166\"><strong>logick\u00fd oper\u00e1tor<\/strong><\/td>\n<td width=\"176\"><strong>Pr\u00edklad<\/strong><\/td>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td width=\"166\"><strong>rovnos\u0165<\/strong><\/td>\n<td width=\"176\">==<\/td>\n<\/tr>\n<tr>\n<td width=\"166\"><strong>nerovnos\u0165<\/strong><\/td>\n<td width=\"176\">!=<\/td>\n<\/tr>\n<tr>\n<td width=\"166\"><strong>je v\u00e4\u010d\u0161\u00ed<\/strong><\/td>\n<td width=\"176\">&lt;<\/td>\n<\/tr>\n<tr>\n<td width=\"166\"><strong>je men\u0161\u00ed<\/strong><\/td>\n<td width=\"176\">&gt;<\/td>\n<\/tr>\n<tr>\n<td width=\"166\"><strong>v\u00e4\u010d\u0161\u00ed alebo rovn\u00fd<\/strong><\/td>\n<td width=\"176\">&lt;=<\/td>\n<\/tr>\n<tr>\n<td width=\"166\"><strong>men\u0161\u00ed alebo rovn\u00fd<\/strong><\/td>\n<td width=\"176\">&gt;=<\/td>\n<\/tr>\n<tr>\n<td width=\"166\"><strong>a z\u00e1rove\u0148 \u2026<\/strong><\/td>\n<td width=\"176\">&amp;&amp;<\/td>\n<\/tr>\n<tr>\n<td width=\"166\"><strong>alebo \u2026<\/strong><\/td>\n<td width=\"176\">||<\/td>\n<\/tr>\n<tr>\n<td width=\"166\"><strong>neg\u00e1cia (opak)<\/strong><\/td>\n<td width=\"176\">!<\/td>\n<\/tr>\n<tr>\n<td width=\"166\"><strong>podmienen\u00fd oper\u00e1tor<\/strong><\/td>\n<td width=\"176\">vyraz1 ? vyraz2 : vyraz3<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Podmienen\u00fd oper\u00e1tor znamen\u00e1, \u017ee pokia\u013e je\u00a0<em>v\u00fdraz1 == true<\/em>, v\u00fdsledkom je\u00a0<em>v\u00fdraz2<\/em>. Pokia\u013e je\u00a0<em>vyraz1 == false<\/em>, v\u00fdsledkom je\u00a0<em>vyraz3<\/em>.<\/p>\n<p><em>Pr\u00edklad:<\/em><\/p>\n<pre>$a = \"7\";\r\n  $b = 7.00;\r\n  echo \"v\u00fdsledok_1 = \".($a == $b);\r\n  echo \"v\u00fdsledok_2 = \".(($a == $b) &amp;&amp; (gettype($a) == gettype($b)));\r\n<\/pre>\n<p><em>V\u00fdsledok pr\u00edkladu:<\/em><\/p>\n<p>v\u00fdsledok_1 = 1<br \/>\nv\u00fdsledok_2 =<\/p>\n<p><em>Pr\u00edklad:<\/em><\/p>\n<pre>$a = 4;\r\n  $b = 5;\r\n  $c = 6;\r\n  echo \"v\u00fdsledok_1 = \".($a == 4 &amp;&amp; $b == 5 &amp;&amp; $c == 6);\r\n  echo \"v\u00fdsledok_2 = \".($a == 3 or $b == 5);\r\n  echo \"v\u00fdsledok_3 = \".!($a == 4 &amp;&amp; $b == 5 &amp;&amp; $c == 6);\r\n<\/pre>\n<p><em>V\u00fdsledok pr\u00edkladu:<\/em><\/p>\n<p>v\u00fdsledok_1 = 1<br \/>\nv\u00fdsledok_2 = 1<br \/>\nv\u00fdsledok_3 =<strong><br \/>\n<\/strong><\/p>\n<h3><strong>3. Bitov\u00e9 oper\u00e1tory<\/strong><\/h3>\n<p>Tieto oper\u00e1tory pracuj\u00fa v bin\u00e1rnom tvare a ka\u017ed\u00fa oper\u00e1ciu vykon\u00e1vaj\u00fa na jednotliv\u00fdch bitoch (PHP pracuje s 32bitov\u00fdmi \u010d\u00edslami).<\/p>\n<table>\n<thead>\n<tr>\n<td width=\"213\"><strong>oper\u00e1cia<\/strong><\/td>\n<td width=\"93\"><strong>Pr\u00edklad<\/strong><\/td>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td width=\"213\"><strong>bitov\u00e9 n\u00e1sobenie<\/strong><\/td>\n<td width=\"93\">x$ &amp; y$<\/td>\n<\/tr>\n<tr>\n<td width=\"213\"><strong>bitov\u00e9 s\u010d\u00edtavanie<\/strong><\/td>\n<td width=\"93\">x$ | y$<\/td>\n<\/tr>\n<tr>\n<td width=\"213\"><strong>bitov\u00e1 neg\u00e1cia<\/strong><\/td>\n<td width=\"93\">x$ ` y$<\/td>\n<\/tr>\n<tr>\n<td width=\"213\"><strong>bitov\u00fd posun doprava<\/strong><\/td>\n<td width=\"93\">x$ &gt;&gt; y$<\/td>\n<\/tr>\n<tr>\n<td width=\"213\"><strong>bitov\u00fd posun do\u013eava<\/strong><\/td>\n<td width=\"93\">x$ &lt;&lt; y$<\/td>\n<\/tr>\n<tr>\n<td width=\"213\"><strong>zmen\u00ed 0 na 1 v prvom \u010d\u00edsle<\/strong><\/td>\n<td width=\"93\">x$ ^ y$<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><em>Pr\u00edklad:<\/em><\/p>\n<pre>echo (6 &amp; 5);\u00a0\u00a0 \/\/ 6 \u00bb 110, 5 \u00bb 101\r\n  echo (6 | 5);\u00a0\u00a0 \/\/ 6 \u00bb 110, 5 \u00bb 101\r\n<\/pre>\n<p><em>V\u00fdsledok pr\u00edkladu:<\/em><\/p>\n<p>4\u00a0\u00a0 \/\/ 4 \u00bb 100<br \/>\n7\u00a0\u00a0 \/\/ 7 \u00bb 111<strong><br \/>\n<\/strong><\/p>\n<p><strong>Echo alebo print?<\/strong><\/p>\n<p>Pr\u00edkaz\u00a0<em>echo<\/em>\u00a0nem\u00f4\u017ee by\u0165 s\u00fa\u010das\u0165ou v\u00fdrazu, preto\u017ee nevracia \u017eiadnu hodnotu.<br \/>\nPr\u00edkaz\u00a0<em>print<\/em>\u00a0hodnotu vracia, tak ho m\u00f4\u017eeme do v\u00fdrazu zaradi\u0165. Inak by mali by\u0165 tieto pr\u00edkazy rovnak\u00e9.<\/p>\n<p><strong>Oper\u00e1tor potla\u010denia chybov\u00fdch hl\u00e1sen\u00ed<\/strong><\/p>\n<p>Oper\u00e1tor\u00a0<em>@<\/em>\u00a0sa pou\u017e\u00edva k vypnutiu chybov\u00fdch spr\u00e1v vstavan\u00fdch funkci\u00ed.<\/p>\n<p><em>Pr\u00edklad:<\/em><\/p>\n<pre>echo \"1. typ: \".(5 \/ 0);\r\n  echo \"2. typ: \".@(5 \/ 0);\r\n<\/pre>\n<p><em>V\u00fdsledok pr\u00edkladu:<\/em><\/p>\n<ol>\n<li>typ:\u00a0<strong>Warning<\/strong>: Division by zero in\u00a0<strong>..cesta..<\/strong>\u00a0on line\u00a0<strong>..riadok..<\/strong><\/li>\n<li>typ:<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>1. Aritmetick\u00e9 oper\u00e1tory Matematick\u00e1 oper\u00e1cia Pr\u00edklad V\u00fdsledok s\u00fa\u010det $cislo = 12+8 20 rozdiel $cislo = 12-8 4 n\u00e1sobenie $cislo = 12*8 96 delenie $cislo = 12\/8 1.5 zvy\u0161ok po delen\u00ed $cislo = 12%8 4 Priorita vykon\u00e1vania oper\u00e1ci\u00ed plat\u00ed ako v matematike. Teda n\u00e1sobenie a delenie s\u00fa vykon\u00e1van\u00e9 sk\u00f4r ako s\u010d\u00edtanie a od\u010d\u00edtanie. Ak chceme najsk\u00f4r [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-345","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/gdm.sosthe.sk\/index.php?rest_route=\/wp\/v2\/pages\/345","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gdm.sosthe.sk\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/gdm.sosthe.sk\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/gdm.sosthe.sk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gdm.sosthe.sk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=345"}],"version-history":[{"count":1,"href":"https:\/\/gdm.sosthe.sk\/index.php?rest_route=\/wp\/v2\/pages\/345\/revisions"}],"predecessor-version":[{"id":346,"href":"https:\/\/gdm.sosthe.sk\/index.php?rest_route=\/wp\/v2\/pages\/345\/revisions\/346"}],"wp:attachment":[{"href":"https:\/\/gdm.sosthe.sk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=345"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}