valid and possible, although I doubt it does what you want it to.
First off, operator precedence.
1. ==
2. |
3 ?:
Thus equivalent to,
( ($string == 'http') | 'www') ? 'URL' : 'file'
So, to evaluate the expression, start with ==
$string == 'http'
possible values: true, false
If it's true:
true | 'www' ? 'URL' : 'file'
If it's false:
false | 'www' ? 'URL' : 'file'
Next up is |
true | 'www'
1
false | 'www'
So, evaluating | yields the same as we got from ==, which means we can just remove that part from the original expression. Thus
($string == 'http') ? 'URL' : 'file';
But even if you started with this I doubt you'd get what you want
($string == ('http' | 'www')) ? 'URL' : 'file';
// which is equal to
($string == 'hwww') ? 'URL : 'file);
What you can do
($string == 'http') ? 'URL' : (($string == 'www') ? 'URL' : 'file');
But I'd much prefer
$url = array('http', 'www');
isset($url[$string]) ? 'URL' : 'file';