IF / ELSE Acronym PHP

I have been trying for the past two hours to write in the shortened conditional expression of PHP below:

public static $url = $_SERVER['HTTP_REFERER']; if (false !== strpos($url,'en')) { $currlang = 'en'; } else { $currlang = 'fr'; } 

I cannot figure out how to do this, although I tried many options and I also read online examples. Could you help me?

0
source share
1 answer
 $currlang = false !== strpos($url, 'en') ? 'en' : 'fr'; 

PHP Manual: Ternary Operator

+5
source

Source: https://habr.com/ru/post/971010/


All Articles