rubing Posted May 26, 2008 Share Posted May 26, 2008 This is a silly question, but google has a hard time searching for atypical characters. Here is a line in a javascript program I am trying to understand: this.url = (smURL||'soundmanager2.swf'); What is the meaning of || ? I thought || meant OR, but that wouldn't make sense in this context. Link to comment https://forums.phpfreaks.com/topic/107356-javascript-use-of/ Share on other sites More sharing options...
trq Posted May 26, 2008 Share Posted May 26, 2008 I does mean or and yes it makes perfect sense. If smURL is true (contains a value) then this.url will be set to its value, otherwise this.url will be set to soundmanager2.swf. Link to comment https://forums.phpfreaks.com/topic/107356-javascript-use-of/#findComment-550443 Share on other sites More sharing options...
rubing Posted May 27, 2008 Author Share Posted May 27, 2008 I've never seen it written that way without an 'if' or at least a ':' Can you write it that way in php? Link to comment https://forums.phpfreaks.com/topic/107356-javascript-use-of/#findComment-550496 Share on other sites More sharing options...
trq Posted May 27, 2008 Share Posted May 27, 2008 Can you write it that way in php? No, the equivelent in php would be.... <?php $url = $smURL ? $smURL : 'soundmanager2.smf'; ?> Link to comment https://forums.phpfreaks.com/topic/107356-javascript-use-of/#findComment-550541 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.