I think this is called compact PHP code or something and I'm guessing the Colon : is the else function but how do I get it to work, this is my current code - but I'd like to put an Else in there for non-IsMobile's: <?php $check = $detect->isMobile(); if($check): ?> <script type="text/javascript"> jwplayer('video-player').setup({ height: 320,... </script> <?php endif; ?> Code (markup):
<?php $check = $detect->isMobile(); if($check): ?> <script type="text/javascript"> jwplayer('video-player').setup({ height: 320,... </script> <?php else : ?> <?php // put your code here ?> <?php endif; ?> PHP:
I'd sooner eat a bullet than open and close PHP that many times, PARTICULARLY the moment you get logic (like IF) involved. I also see no reason to waste an extra variable on that. <?php if ($detect->isMobile()) { echo ' <script type="text/javascript"><!-- jwplayer(\'video-player\').setup({ height: 320,... }); --></script>'; } else { echo ' Whatever your other code is'; } ?> Code (markup): Though you shouldn't be browser sniffing server side over something like a video file in the first place. You're using jwplayer, why aren't you embedding your various formats? Again though, I'd be pitching jwPlayer in the trash since it's doesn't let you just use the proper damned markup yourself; and has no scripting off graceful degradation.
Yep it's all down to JWplayer, you can offer multiple formats but it will play the first file only and playlist the rest.
Actually you can do multiple files per play-item -- it's called "levels"; I forget how to use it through, I only used jwplayer long enough to go "this is trash".
Hi, Do you use this simple code.... <?php $check = $detect->isMobile(); if(empty($check)) { echo"some text": } else {?> <script type="text/javascript"> jwplayer('video-player').setup({ height: 320,... </script> <?php endif; ?>