PHP 提交按钮在使用分解功能时不起作用


php submit button not working while using explode function

以下是我通过按钮调用php函数的代码。但是我单击的按钮没有触发该功能。

<form method="POST" action="">
    <div class="navbar-collapse collapse" id="navbar-main">
                <ul class="nav navbar-nav navbar-right">
                    <li style="padding:10px;">
                        <button type="submit" name="imp" id="subDownload" class="btn btn-success subDownload" value="download"> <span class="glyphicon glyphicon-envelope"></span> Send Email</button> 
                    </li>
                </ul>
            </div>
              <div id="address" >
                    <h4>To:</h4>
                    <textarea id="address" name="invoice_address_to" class="form-control input-noshow" rows="6" cols="35">
Some Company
Address 1
Address 2
Zipcode
State
Country
                    </textarea>
                </div>
            </div>

</form>

<?php 
function test()
{
print_r (explode('/n',invoice_address_to));
}
if (isset($_POST['imp'])) {
        test();
    }
?>

谁能帮我解决这个问题。

您发布的文本未提交到功能测试。您可以通过使用以下代码更新 php 代码来做到这一点

<?php 
function test($string)
{
    #print_r(explode('/n',$string));
    var_dump($string);
}
if (isset($_POST['imp']))
{
    test($_POST['invoice_address_to']);
}
?>