Quick Guide conditional if
Author: admin | Monday, February 20, 2012, 21:05 hours | Read 29834 times
More than once I was looking on the internet write a summary of the conditionally if. It is often useful, especially when assigning a value to a variable. In this case it is a conditional assignment of values for the variable.
There is not much to write, these things are best explained and illustrated with examples.
Standard Operational if:
Slightly shorter version of the manual if:
very short version of the manual if:
What, in practice, for example, looked at me like this:

Standard Operational if:
if ($ Condition) { / / Do the if $ condition is true } else { / / Do the if $ condition is not satisfied }
Slightly shorter version of the manual if:
if ($ Condition) / / Do the if $ condition is true else / / Do the if $ condition is not satisfied
very short version of the manual if:
($ Condition) ? / * Do if $ condition is true * / : / * Do if $ condition is not satisfied * /;
What, in practice, for example, looked at me like this:
$ Jezyk_strony = (!$ _GET['Jezyk_strony']) ? $ Cfg['Domyslny_jezyk_strony'] : $ _GET['Jezyk_strony'];
Tags:
Related entries:
-
A tutorial on creating web sites for beginners - CSS, HTML, PHP, MySQL, JavaScript
Comments:
Add a comment
Tag cloud
- css
- CSS3
- editor
- html editor
- javascript editor
- php editor
- html
- iframe
- The conditional statement
- The conditional statement if
- jedit
- course page creation
- mysql
- notebook
- php
- web design
- frame in html
- reduced if
- page on the frame
- html tables
- creating pages css
- web development
- creating pages on tables
- defects in the frame-
- rounded corners
Archive
Statystyki
czas generowania - całkowity: 0.386 sek.
czas generowania - MySQL: 0.3535 sek.
czas generowania - PHP: 0.0326 sek.
czas generowania - translator: 0.3555 sek.
Ilość przetłumaczonej treści: 98 %
ilość zapytań MySQL: 69
wykorzystana pamięć RAM: 1 290,85 kb
As a curiosity append the operator introduced in PHP Elvis and you can even shorten the record even more :) but showing an example:
In PHP 5.2 and lower ...
$ Jezyk_strony = ($ _GET ['jezyk_strony'])? $ _GET ['Jezyk_strony']: $ cfg ['domyslny_jezyk_strony'];
In PHP 5.3:
$ Jezyk_strony = ($ _GET ['jezyk_strony'])?: $ Cfg ['domyslny_jezyk_strony'];