'include'에 해당되는 글 3건
- 2008/10/27 How to include file in JSP ?
- 2008/01/25 How to include Javascript from anonther ?
- 2007/10/16 How to include a file with error reporting ?
Here's the simple example.
Actually there is such a function in PHP which function is include".
It's very strong function.
But Javascript does not support such a function.
Here's the alternate method to do that.
To include javascript, following is using usually:
<script type="text/javascript" src="the_script.js"></script>
But above script is not available in Javascript so following is the alternate method to include another javascript.
the_another_javascript.js:
document.write( "<script type=\"text/javascript\" src=\"the_script.js\"></script>");
Isn't it simple ?
Actually the main logic above is writing script tag in the document.
<?php
$includefile="foo.php";
//using fopen to verify file. the third parameter triggers include_path search
$handle = fopen($includefile, "r", 1);
if ($handle) {
fclose($handle);
include ($includefile);
} else {
echo "file: $includefile not found in path";
echo "handle is: $handle";
}
?>
$includefile="foo.php";
//using fopen to verify file. the third parameter triggers include_path search
$handle = fopen($includefile, "r", 1);
if ($handle) {
fclose($handle);
include ($includefile);
} else {
echo "file: $includefile not found in path";
echo "handle is: $handle";
}
?>
Here's another example much better simple than the above. As you can see, just add @ in front of the function you will use. By '@', the error message will be ignored. (not be shown)
<?php
@include "foo.php";
?>
@include "foo.php";
?>

Prev

Rss Feed