I want to write a block for my own use only, but not to be visible when the page is read in a browser.
Maybe commenting it?
HTML:
<!-- comment... -->
PHP:
/* comment 1 */
// comment 2
# comment 3
Something like this might work for you:
<html>
<head>
<title>My Title</title>
</head>
<body>
<?php
/*
This is a server side comment that will not be visible on the client side.
*/
?>
</body>
</html>
I usually do it like this:
<?php
// code for them
if (isset($_GET['debug'])) {
// code for me
}
?>
When I need access to the debug code, i just browse to http://mysite.com/page.php?debug
Obviously, this isn't secure. Anybody can simply add ?debug
to the URL and see your debug info. This would be something to use during initial development of a one-off script hosted locally, and is not suitable for use on a public-facing site.
You can use comments like // /* */ and # http://php.net/manual/en/language.basic-syntax.comments.php
It's the only way that visitors won't see your text blocks.
精彩评论