Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Jak tego if'a przekształcić z postaci (1==1?1:0) skróconej do pełnej?
Neutral
post
Post #1





Grupa: Zarejestrowani
Postów: 286
Pomógł: 46
Dołączył: 10.01.2016

Ostrzeżenie: (0%)
-----


Mam takiego if'a: $a = true ? 0 : true ? 1 : 2;
Chcę to zrobić na postać:
if(){

}elseif(){

}else{

};

Ten post edytował Neutral 14.08.2016, 14:37:51
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 3)
Pyton_000
post
Post #2





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

Ostrzeżenie: (0%)
-----


a w czym problem?
Go to the top of the page
+Quote Post
Neutral
post
Post #3





Grupa: Zarejestrowani
Postów: 286
Pomógł: 46
Dołączył: 10.01.2016

Ostrzeżenie: (0%)
-----


  1. echo(true ? 0 : true ? 1 : 2);
will output: 2
  1. <?php
  2. if(true){
  3. echo 0;
  4. }elseif(true){
  5. echo 1;
  6. }else{
  7. echo 2;
  8. }
  9. ?>

will output: 0

Mam inny wynik po przekształceniu na if'a. Nie wiem jak to poprawnie zapisać.
Go to the top of the page
+Quote Post
markuz
post
Post #4





Grupa: Zarejestrowani
Postów: 1 240
Pomógł: 278
Dołączył: 11.03.2008

Ostrzeżenie: (0%)
-----


Potraktuj to w ten sposób:
Kod
(true ? 0 : true) ? 1 : 2
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 25.08.2025 - 06:45