Reputation: 8346
I have following 2 php pages which is actually containing html tags (in 2nd page only) with out php tag start and end.
page1.php
<div>Page 1</div>
<?php exec('/usr/bin/php page2.php');
?>
page2.php in same directory
<div> this is page 2</div>
Actual result : 2nd page is not printed when page1.php is executed
Expected result: both page 1 and page 2 php result should come in page1.php when hit from broswer.. in this case , following is the expected result..
Page 1
this is page 2
Note : This is just an example. my page is containing 1000s of lines in page2.php
Upvotes: 0
Views: 132
Reputation: 1
<input type="hidden" name="id" value="<?=$data['id_rm']?>">
<label for="pasien">Nama Pasien</label>
<select name="pasien" id="pasien" class="form-control" required>
<option value="<?=$data['id_pasien']?>" selected="selected"><?=$data['nama_pasien']?></option>
<option value="">- Pilih Pasien -</option>
<?php
$sql_pasien = mysqli_query($con, "SELECT * FROM tb_pasien") or die(mysqli_error($con));
while($data_pasien = mysqli_fetch_array($sql_pasien)) {
echo '<option value="'.$data_pasien['id_pasien'].'">'.$data_pasien['nama_pasien'].'</option>';
}
?>
</select>
Upvotes: 0
Reputation: 997
You can use it multiple time in a php file
<div>Page</div>
<?php
include once "page2.php";
or
require once "page2.php";
?>
Upvotes: 0
Reputation: 1
Use the following on page1.php:
<div>Page 1</div>
<?php
include ("page2.php");
?>
Hope that works for you... :)
Upvotes: 0
Reputation: 179994
Per the docs, exec
only returns (i.e. you'd have to echo it) the last line of the output. passthru
or system
would work better, but you really should be using include
or require
instead.
Upvotes: 2
Reputation: 1491
You're looking for require or include (or in particular, probably require_once)
i.e.
<div>Page 1</div>
<?php
require("page2.php");
?>
Unless you're trying to do something far stranger than i've anticipated.
Upvotes: 3