Include Functions PHP -
i have php file include functions , css page. trying make include function generate of html. can not figure out how css file in php include function made.
<?phpe function htmlstart( $title) { echo "<!doctype html>\n"; echo "<html>\n"; echo "<head>\n"; echo " <title>".$title."</title>\n"; echo " <link href=\ 'inclab.css' type=\"text/css\" rel=\"stylesheet\" />\n"; echo "</head>\n"; echo "<body>\n"; } ?>
the problem have echo
line:
echo " <link href=\ 'inclab.css' type=\"text/css\" rel=\"stylesheet\" />\n";
i tried use double quotes , error, tried use single quotes "inclab.css , got no error. wounding if right way it.
also, made navigation bar in include file how put in class (for css) links line correctly.
<?php function pagenagivation() { echo "<!-- nav of page --> \n"; echo "<nav> \n"; echo '<div class="nav-item float-left"> <a href="inclabpage1.php">page 1</a>'; echo '<div class="nav-item end-float"> <a href="inclabpage2.php">page 2</a>'; echo "</nav> \n"; } ?>
the navigation bar works , display not display correctly. problem know lies <div class....
part of code. how work. thanks.
for quote problem, yes acceptable use single quotes in situation, that's for. escaping 1 of them, don't need do:
echo "<link href='inclab.css' type='text/css' rel='stylesheet' />\n";
for adding class, can input html like:
echo '<div class="nav-item end-float myclass"> <a href="inclabpage2.php">page 2</a>';
or, if stored in variable:
echo '<div class="nav-item end-float '.$myclass.'"> <a href="inclabpage2.php">page 2</a>';
or
echo '<div class="nav-item end-float $myclass"> <a href="inclabpage2.php">page 2</a>';
Comments
Post a Comment