[英]syntax error T_PAAMAYIM_NEKUDOTAYIM!
buy.php: buy.php:
<form action="cart.php" method="post">
<?php foreach($product['varieties'] as $variety): ?>
<input style="width:10px; margin-left:9px; " name="price[]" type="checkbox" value="<?php echo $variety['price'] . '_' . $variety['size']; ?>" />';
<?php end foreach; ?>
</form>
cart.php: cart.php:
list($aDoor, size) = split('_', $_POST['price']); // line 207
if(empty($aDoor))
{
echo("You didn't select any buildings.");
}
else
{
echo "Sum of vlues = ".array_sum($aDoor);
}
In cart.php there is the following syntax error: 在cart.php中,存在以下语法错误:
syntax error, unexpected ')', expecting T_PAAMAYIM_NEKUDOTAYIM in store/cart.php on line 207 语法错误,意外的')',预计在207行的store / cart.php中为T_PAAMAYIM_NEKUDOTAYIM
I am expecting in cart.php to receive the two index values size and price independetly so I can use it and CSS it where ever i want. 我希望在cart.php中可以独立接收两个索引值的大小和价格,因此我可以在需要的地方使用它和CSS。 I am expecting that with the function list() and split() the variables variety and $aDoor with the price value will able to separate this two variables to be use wherever I want in cart.php 我期望通过函数list()和split()将变量variant和具有价格值的$ aDoor分隔开两个变量,以便在cart.php中的任何位置使用
Help. 救命。
Missing a $
: 缺少$
:
list($aDoor, $size) = split('_', $_POST['price']); // line 207
I think you are trying to do something like: 我认为您正在尝试执行以下操作:
<?php
$aDoor = array();
$size = array();
foreach ($_POST['price'] as $p)
{
list($a, $b) = explode('_', $p);
$aDoor[] = $a;
$size[] = $b;
}
if(empty($aDoor))
{
echo("You didn't select any buildings.");
}
else
{
echo "Sum of vlues = ".array_sum($aDoor);
}
?>
It's Hebrew. 是希伯来语。 It means twice colon. 这意味着两次冒号。 It also happens when you miss the $, like you have. 如您一样,当您错过$时,也会发生这种情况。
http://en.wikipedia.org/wiki/Scope_resolution_operator#PHP http://en.wikipedia.org/wiki/Scope_resolution_operator#PHP
@Konforce I test your script and it works good. @Konforce我测试了您的脚本,效果很好。
Sorry I don't know what I was saying but I have to work it like this to list $size and prices $aDoor with the total below. 抱歉,我不知道我在说什么,但是我必须像这样工作,以列出$ size,并在下面列出价格$ aDoor。 I just have to style it now. 我现在必须设置样式。
<?php
list($aDoor, $size) = split('_', $_POST['price']);
$aDoor = array();
$size = array();
foreach ($_POST['price'] as $p)
{
list($a, $b) = explode('_', $p);
$aDoor[] = $a;
$size[] = $b;
}
if(empty($aDoor))
{
echo("You didn't select any buildings.");
}
else
{
$V = count($size);
for($i=0; $i < $V; $i++)
{
echo($size[$i] . " ");
}
$A = count($aDoor);
for($i=0; $i < $A; $i++)
{
echo($aDoor[$i] . " ");
}
echo "Sum of vlues = ".array_sum($aDoor);
}
?>
@konforce can you see at the begining where you have set up the variable $aDoor and $size as arrays? @konforce可以在开始时看到将变量$ aDoor和$ size设置为数组的地方吗?
$aDoor = array();
$size = array();
Well now I am adding another index value that is not an array it is an string 好吧,现在我要添加另一个索引值,该值不是数组,而是一个字符串
<input style="width:10px; margin-left:9px; " name="price[]" type="checkbox" value="' . $variety['price']. '_'. $variety['variety'] '_'. $product['name'].'" />
you see the '. 您会看到'。 $product['name'].' $ product ['name']。 well how can I receive it in cart.php in cart.php you have done the script as below but those are for arrays this time this one is not an array and I am seding it through the same form input. 好吧,如何在cart.php中的cart.php中接收它,您已经完成了如下脚本,但是这次是针对数组的,这不是数组,我通过相同的表单输入对其进行了处理。
$aDoor = array();
$size = array();
foreach ($_POST['price'] as $p)
{
list($a, $b) = explode('_', $p);
$aDoor[] = $a;
$size[] = $b;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.