我正在使用把手,需要获取值的特定部分。
通常,我知道我可以只使用<?php
ob_start();
include_once __DIR__.'/header2.php';
if (!$_SESSION['u_uid']) {
echo "<meta http-equiv='refresh' content='0;url=index.php?donation=notlogin'>";
exit();
} else {
include_once __DIR__.'/includes/dbh.php';
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
header("Location: index.php");
exit();
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2);
curl_setopt($ch, CURLOPT_URL, 'https://ipnpb.sandbox.paypal.com/cgi-bin/webscr');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "cmd=_notify-validate&" . http_build_query($_POST));
$response = curl_exec($ch);
curl_close($ch);
if ($response == "VERIFIED" && $_POST['receiver_email'] === "admin@pianocourse101.com") {
$cEmail = strip_tags($_POST['payer_email']);
$firstname = strip_tags($_POST['first_name']);
$lastname = strip_tags($_POST['last_name']);
$price = strip_tags($_POST['mc_gross']);
$currency = strip_tags($_POST['mc_currency']);
$item = strip_tags($_POST['item_number']);
$paymentStatus = strip_tags($_POST['payment_status']);
if ($item == "Donation" && $currency == "USD" && $paymentStatus == "Completed" && $price == 100) {
$sql = "INSERT INTO donation (user_email, firstname, lastname, amount) VALUES (?,?,?,?);";
$stmt = mysqli_stmt_init($conn);
if(!mysqli_stmt_prepare($stmt, $sql)) {
echo "SQL error";
} else {
mysqli_stmt_bind_param($stmt, "sssi", $cEmail, $firstname, $lastname, $price);
mysqli_stmt_execute($stmt);
}
}
}
}
?>
;但是,该值位于长字符串的末尾,并且其前的字符数将不会是一致的长度。
在下面的示例中,我试图在两种情况下都获取982。注意,参数“ referral_code”将始终相同。
substring
http://www.website.com/?referral_code=982
是否有任何Handlebars函数(或使用http://www.website.com/subpage/?referral_code=982
的方法)可以使我从以上两个实例中获得substring
?
谢谢!