2017-06-16 8 views
-4

A PHPエラーはあなたが異なっそれを記述する必要がこれはどういう意味ですか?致命的なエラー:書き込みコンテキストで関数の戻り値を使用することはできません

Severity: Compile Error
Message: Can't use function return value in write context
line number:116
floor($BudgetPerPerson) = $TotalBudget/$NumberOfPeople;

label class="heading">How much is your budget? :</label> 
<br><br> 
<input name="TotalBudget" placeholder="Budget " class="form-control" type="text"> 
<br><br> 
</center> 
<!----- Including PHP Script -----> 
<label class="heading">How many guest do you intend to invite? :</label> 
<br><br> 
<input name="NumberOfPeople" placeholder="Number Of People" class="form-control" type="text"><br><br> 
</center> 
<input type="submit" name="submit" Value="Submit"/> 
<!----- Including PHP Script -----> 

<?php 

this part i think is wrong

$TotalBudget= ($_POST['Budget']); 
    $people = ($_POST['NumberOfPeople']); 
    $BudgetPerPerson = $TotalBudget/$people; 
//Calculate the Budget Per Person 

$BudgetPerPerson = floor($TotalBudget/$NumberOfPeople); 



//The $BudgetPerPersonmust now fit a package price 
if($BudgetPerPerson == "17") { 
echo "You have Package A"; 
} 
elseif($BudgetPerPerson == "19") { 
echo "You have Package B"; 
} 
if($BudgetPerPerson == "22") { 
echo "You have Package C"; 
} 
if($BudgetPerPerson == "20") { 
echo "You have Package D"; 
} 
if($BudgetPerPerson == "25") { 
echo "You have Package E"; 
} 
//Since Package D is the most expensive, if the $BudgetPerPerson is equal to or higher than 20 it will automatically select Package D 
elseif($BudgetPerPerson >= "27") { 
echo "You have Package F"; 
} 
else { 
//This code will execute when the price per package is too low 
echo "The amount of people is too high for the budget, please increase your budget or reduce the number of people to receive a package quotation."; 
}else { 
//Calculate the Difference between the lowest package price and the offered price 
ceil($Difference) = ((17 - $BudgetPerPerson) * $NumberOfPeople) 
//This code will execute when the price per package is too low 
echo "Your budget is too low for the amount of people. Please increase your budget by: $" . $Difference . " to be able to reserve a package"; 
} 

?> 
+2

あなたが今しようとしているような機能の結果に番号を割り当てられない可能性があります - 閉じるに投票しました – mplungjan

答えて

3

を発生しました:

$BudgetPerPerson = floor($TotalBudget/$NumberOfPeople); 
012第二の問題について

は、ここにエラーがあります:

$TotalBudget= ($_POST['Budget']); 
$people = ($_POST['NumberOfPeople']); 
$BudgetPerPerson = $TotalBudget/$people; 
//Calculate the Budget Per Person 

$BudgetPerPerson = floor($TotalBudget/$NumberOfPeople); 

あなたの変数は$people代わりの$NumberOfPeopleと呼ばれています。

このような変更を:

$TotalBudget= ($_POST['Budget']); 
$people = ($_POST['NumberOfPeople']); 
//Calculate the Budget Per Person 
$BudgetPerPerson = floor($TotalBudget/$people); 
+0

私はコーディングがあまり良くありません。この変数を宣言する方法を教えてください。 $ BudgetPerPerson = floor($ TotalBudget/$ NumberOfPeople);なぜなら私は定義されていない変数にエラーがあるからです。 –

+0

@ ZureenFarisyaつまり、 '$ TotalBudget'や' $ NumberOfPeople'、あるいはその両方があなたのコードにまだ存在していないか、値がありません。しかし、それはもう一つの質問です。もっとコードを表示する必要があります。 – FMashiro

+0

ここに私は完全なコードを与えます –

0

あなたは割り当ての左側にある関数を使用します。

関連する問題