好吧,如果我评论某些内容,它在所有语言中都会被跳过,但是它们是如何跳过的以及读取的内容是什么?
Example:
// This is commented out
现在 PHP 是读取整个注释以转到下一行还是只读取//
?
该脚本被解析并分为tokens.
实际上,您可以使用任何有效的 PHP 源代码自己尝试一下token_get_all() http://www.php.net/manual/en/function.token-get-all.php,它使用 PHP 的本机分词器。
手册中的示例显示了如何处理注释:
<?php
$tokens = token_get_all('<?php echo; ?>'); /* => array(
array(T_OPEN_TAG, '<?php'),
array(T_ECHO, 'echo'),
';',
array(T_CLOSE_TAG, '?>') ); */
/* Note in the following example that the string is parsed as T_INLINE_HTML
rather than the otherwise expected T_COMMENT (T_ML_COMMENT in PHP <5).
This is because no open/close tags were used in the "code" provided.
This would be equivalent to putting a comment outside of <?php ?>
tags in a normal file. */
$tokens = token_get_all('/* comment */');
// => array(array(T_INLINE_HTML, '/* comment */'));
?>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)