php包含条件注释

I included some jQuery script on my site. The script doesn't work with anything lower than IE7. Now I want to do the following:

<!--[if !(lt IE 7]>
    <?php include 'script.html'; ?>
<![endif]-->

It should only load the script if the browser is "not lower than IE7". But it doesn't work.

Is there any way to solve this without using a PHP based browser recognition?

Yes, build the browser recognition into your jQuery/javascript. In the javascript, test for capability or object you're needing, and if it's not there, then have code to deal with it.

could be the opening ( that doesn't have a closing ) ?

Help with the first part: it doesn't work because you don't need the ( before lte, nor the !. Use

<!--[if gte IE 7]>
  <?php include 'script.html'; ?>
<![endif]-->

Further reading: Microsoft's page on IE conditional comments

another alternative can be to use the well known ie7.js script that makes older IE versions more "standard" compliant that would surely make your jQuery script work.

you can find it here

You shouldn't be using browser detection. Instead, use Feature Detection to test if your browser is capable of something you want to do.

in php you would do one of the following

$browser = get_browser(null, true);
if($browser['browser'] == 'MSIE' && $browser['version'] >= 7) { /*CODE*/

OR

$u_agent = $_SERVER['HTTP_USER_AGENT']; 
$bname = 'Unknown';
$version= "";

if(preg_match('/MSIE/i',$u_agent) && !preg_match('/Opera/i',$u_agent)) 
{ 
    $bname = 'Internet Explorer'; 
} 

// finally get the correct version number
$known = array('Version', $ub, 'other');
$pattern = '#(?<browser>' . join('|', $known) .
')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#';
if (!preg_match_all($pattern, $u_agent, $matches)) {
    // we have no matching number just continue
}

The IE Conditional statements only work after the page has been sent to the browser so PHP include files will not work, To include a JS script file you would use

<!--[if !(lt IE 7]>
<script src='script.js' type='text/javascript'></script>
<![endif]-->

For a javascript browser detection you would use:

if(BrowserDetect.browser == "MSIE" && BrowserDetect.version >= '7') {
   /* CODE */
}