I'm trying to check whether a $_POST exists and if it does, print it inside another string, if not, don't print at all.

something like this:

$fromPerson = '+from%3A'.$_POST['fromPerson'];

function fromPerson() {
    if !($_POST['fromPerson']) {
        print ''
    } else {
        print $fromPerson
    };
}

$newString = fromPerson();

Any help would be great!

推荐答案

if( isset($_POST['fromPerson']) )
{
     $fromPerson = '+from%3A'.$_POST['fromPerson'];
     echo $fromPerson;
}

Php相关问答推荐

Laravel 10查询中的多个where子句

Postgrid Webhook不叫laravel

Laravel中的通配符Undot数组

PHP:从数组中获取唯一的数字组合

显示WooCommerce当前产品类别或标签的短代码

在WooCommerce管理订单列表中显示项目总权重

Htaccess-重写对&api.php";的API请求以及对";web.php";的其他请求

从WooCommerce订单状态更改更新用户自定义元数据

将日期数组排序为年->;月

在WooCommerce中添加特定产品类型的百分比费用和固定费用

如何使用定制的StateProvider设置JsonLd@上下文?

限制联系人页面仅允许在WooCommerce中登录的用户

PHP按另一个二维数组的排序顺序对二维数组进行排序

Mac 上安装 php 时出现 Homebrew 错误

使用帖子 ID 更新 wp 帖子

如何在 PHP laravel 中将图像的透明背景转换为白色?

使用 Spomky Labs JWT 框架中的 verifyWithKey 验证 id_token JWT 的签名需要 30 秒以上

NetBeans 不显示中文内容

我想更新表格中的结果并将它们发布到浏览器,但它不起作用

如何通过本地主机在同一台 PC 上同时运行 Microsoft IIS 和 WAMP