I have a site architechure where I assign content to variables and then print them in a master page. My problem is that php code in the sub pages is imported into the variables as strings. Is there anyway to make sure that the code is actually executed and the results is imported in the variables instead?
In the example below the php code in signup_header.php is imorted as a string to $page_header. The result is that "getVerifiedEmail(); ?>" is displayed in the form element instead of the e-mail address.
master.php
<!DOCTYPE HTML>
<html>
<head>
<?php echo $page_header; ?>
</head>
<body id="home">
<div class = "container">
<?php echo $page_content; ?>
</div>
</body>
</html>
signup.php:
<?php
$page_content = file_get_contents("./include/signup_content.php");
$page_header = file_get_contents("./include/signup_header.php");
include('master.php');
?>
signup_header.php
<script type="text/javascript">
$(document).ready(function(){
$('input[name="name"]').attr('value', "<?php echo $idpAssertion->getVerifiedEmail(); ?>");
});
</script>
signup_content.php
<section>
<form class="task" method="POST">
Name: <input type="text" name="name" maxlength="30" value=""/><br/>
Email: <input type="text" name="email" value=""/><br/>
UserId: <input id="userId" type="text" name="userId" value="" /><br/>
</form>
</section>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…