Greetings! I’m very new to PHP programming and I have just learned how to send data from
input page to another page using form tag, below are my code.
・index.html
heredoc input 1input 2
・check.php
<?php $a=$_POST['input1']; $b=$_POST['input2']; $display = <<<heredoc$a | $b |
Result
[table]
[tr]
[td][input1][/td]
[td][input2][/td]
[/tr]
[/table]
what I want to achieve is
・I want the html part to be on external file
Then I tried several patterns
pattern #1
・check.php
<?php $a=$_POST['input1']; $b=$_POST['input2']; $display = <<・check.html
$a | $b |
Result
include(‘check.html’);
it displays plain text between heredocument function.
pattern #2
・check.php
<?php $a=$_POST['input1']; $b=$_POST['input2']; $ext=include 'check.html'; $string = <<Result
$a $b
1
it displays table and text of the variable itself, the variable is not converted to data from index.html
and I have no idea why “1” is displayed.
pattern #3
・check.php
<?php $ext='ext'; function ext() { $gaibu = include('check.html'); return $gaibu; } $string = <Result is the same on pattern #2, based on what I have researched if you want to use function inside heredoc
statement you have to put the function inside a variable and call it with {}
My question is
・how can I pass the data to the variable($a,$b) using external file(include() or require())?
・does external file have to be a php file?
・are there any other better techniques?
・is what I want to achieve possible?
I’ve been reading alot of forums but I can’t seem to solve it, appreciate any help Regards.