0
我有2個PHP文件file1.php
一些全球可變因素包含文件和功能PHP
和file2.php
幾個功能後有些X的條件不改變的文件下載1變量的值。
我唯一的問題file1.php
其中包括file2.php
不會回顯/返回值。代碼如下:
file1.php
if ($result) {
if ($result['image'] && file_exists(RC_UPLOADS_DIR . "vehicle_" . $result['image'])) {
$image = RC_UPLOADS_URL . 'vehicle_' . $result['image'];
$image_thumb = RC_UPLOADS_URL . 'cache/' . rc_image_resize(RC_UPLOADS_DIR . "vehicle_" . $result['image'], 160, 120);
} else {
$image = '';
$image_thumb = '';
}
$description = preg_replace(array("/\s\s/", "/\r\r/", "/\n\n/"), '<br />', trim($result['description']));
$vehicle_meta = rc_getVehicleMeta($vehicle_id);
global $GeneralPrice, $discount_price, $rent, $rent1, $rent2, $rent3,$rent4, $rent5, $rent6, $rent7, $rent8, $rent9, $rent10, $rent11, $rent12, $rent13, $rent14, $rent15, $rent16, $rent17, $rent18, $rent19, $rent20, $rent21, $rent22, $rent23, $rent24, $rent25, $rent26, $rent27, $rent28, $rent29, $rent30, $rent31, $rent32, $rent33, $rent34, $rent35, $rent36;
$rent = $result['rent'];
$rent1 = $vehicle_meta['rent1'];
$rent2 = $vehicle_meta['rent2'];
$rent3 = $vehicle_meta['rent3'];
$rent4 = $vehicle_meta['rent4'];
$rent5 = $vehicle_meta['rent5'];
$rent6 = $vehicle_meta['rent6'];
$rent7 = $vehicle_meta['rent7'];
$rent8 = $vehicle_meta['rent8'];
$rent9 = $vehicle_meta['rent9'];
$rent10 = $vehicle_meta['rent10'];
$rent11 = $vehicle_meta['rent11'];
$rent12 = $vehicle_meta['rent12'];
$rent13 = $vehicle_meta['rent13'];
$rent14 = $vehicle_meta['rent14'];
$rent15 = $vehicle_meta['rent15'];
$rent16 = $vehicle_meta['rent16'];
$rent17 = $vehicle_meta['rent17'];
$rent18 = $vehicle_meta['rent18'];
$rent19 = $vehicle_meta['rent19'];
$rent20 = $vehicle_meta['rent20'];
$rent21 = $vehicle_meta['rent21'];
$rent22 = $vehicle_meta['rent22'];
$rent23 = $vehicle_meta['rent23'];
$rent24 = $vehicle_meta['rent24'];
$rent25 = $vehicle_meta['rent25'];
$rent26 = $vehicle_meta['rent26'];
$rent27 = $vehicle_meta['rent27'];
$rent28 = $vehicle_meta['rent28'];
$rent29 = $vehicle_meta['rent29'];
$rent30 = $vehicle_meta['rent30'];
$rent31 = $vehicle_meta['rent31'];
$rent32 = $vehicle_meta['rent32'];
$rent33 = $vehicle_meta['rent33'];
$rent34 = $vehicle_meta['rent34'];
$rent35 = $vehicle_meta['rent35'];
$rent36 = $vehicle_meta['rent36'];
include_once('files2.php');
$vehicle = array(
'vehicle_id' => $result['vehicle_id'],
'title' => $result['manufacturer']." ".$result['series'],
'manufacturer' => $result['manufacturer'],
'series' => $result['series'],
'year' => $result['year'],
'class' => $result['class'],
'image' => $image,
'image_thumb' => $image_thumb,
'description' => $description,
'seats' => $vehicle_meta['seats'],
'doors' => $vehicle_meta['doors'],
'baggages' => $vehicle_meta['baggages'],
'conditioning' => $vehicle_meta['conditioning'],
'transmission' => $vehicle_meta['transmission'],
'total_price' => $rc_currency->format((($rental_days*$GeneralPrice)-($rental_days*$GeneralPrice)* ($discount_price)/100)+ $total_extras),
'total_price_return_fee' => $rc_currency->format((($rental_days*$GeneralPrice)-($rental_days*$GeneralPrice)* ($discount_price)/100)+ $xfee + $total_extras),
'total_price_return_fee' => $rc_currency->format((($rental_days*$GeneralPrice)-($rental_days*$GeneralPrice)* ($discount_price)/100)+ $xfee2 + $total_extras),
'daily_price' => $rc_currency->format((($GeneralPrice)-($GeneralPrice)* ($discount_price)/100)+ $excess_price),
'daily_price_return_fee' => $rc_currency->format((($GeneralPrice)-($GeneralPrice)* ($discount_price)/100)+ ($xfee/$rental_days)),
'daily_price_return_fee2' => $rc_currency->format((($GeneralPrice)-($GeneralPrice)*($discount_price)/100)+ ($xfee2/$rental_days))
);
}
return $vehicle;
}
File2.php
<?php
//Out of Season function
function outofseason(){
global $rental_days, $GeneralPrice, $discount_price, $days1,$discount1, $days2, $discount2, $days3, $discount3, $rent;
//Discount with Duration
$days1 = get_field('days');
$discount1 = get_field('discount_days1');
$days2 = get_field('days2');
$discount2 = get_field('discount_days2');
$days3 = get_field('days3');
$discount3 = get_field('discount_days3');
$GeneralPrice = $rent;
if($rental_days > $days1 && $rental_days < $days2){
return $discount_price = $discount1;
}elseif($rental_days > $days2 && $rental_days < $days3){
return $discount_price = $discount1 + $discount2;
}elseif($rental_days > $days3 && $discount3 !=0){
return $discount_price = $discount1 + $discount2 + $discount3;
}else{
return $discount_price = 0;
}
}
//Seasons
function Seasonlow() {
global $rental_days, $GeneralPrice, $discount_price, $season_start_date_low, $season_end_date_low, $rent1, $rent2, $rent3, $rent4, $rent5, $rent6, $rent7, $rent8, $rent9;
//Date calculator
$datetime1 = '2014-02-05';
$datetime2 = '2014-04-15';
$duration = 86400 ;
$days_dur = ceil(strtotime($datetime2)-strtotime($datetime1))/$duration;
//$season_start_date_low = '05/02/2014';
//$season_end_date_low = '15/02/2014';
$pickupdate = $_GET['pickup_date'];
$returndate = $_GET['return_date'];
//if($pickupdate >= $season_start_date_low && $returndate <= $season_end_date_low){
if($rental_days == 1){
return $GeneralPrice = $rent1;
$discount_price = 0;
}elseif($rental_days == 2){
return $GeneralPrice = $rent2;
$discount_price = 0;
}elseif($rental_days == 3){
return $GeneralPrice = $rent3;
$discount_price = 0;
}elseif($rental_days == 4){
return $GeneralPrice = $rent4;
$discount_price = 0;
}elseif($rental_days == 5){
return $GeneralPrice = $rent5;
$discount_price = 0;
}elseif($rental_days == 6){
return $GeneralPrice = $rent6;
$discount_price = 0;
}elseif($rental_days >= 7 && $rental_days <= 13){
return $GeneralPrice = $rent7;
$discount_price = 0;
}elseif($rental_days >= 14 && $rental_days <= 20){
return $GeneralPrice = $rent8;
$discount_price = 0;
}elseif($rental_days >= 21){
return $GeneralPrice = $rent9;
$discount_price = 0;
}
//}else {
//outofseason();
//}
}
//Season Mid
function Seasonmid() {
global $rental_days, $GeneralPrice, $discount_price, $season_start_date_mid, $season_end_date_mid, $rent10, $rent11, $rent12, $rent13, $rent14, $rent15, $rent16, $rent17, $rent18;
//Date calculator
$datetime1 = '2014-02-05';
$datetime2 = '2014-04-15';
$duration = 86400 ;
$days_dur = ceil(strtotime($datetime2)-strtotime($datetime1))/$duration;
//$season_start_date_mid = '05/03/2014';
//$season_end_date_mid = '15/03/2014';
$pickupdate = $_GET['pickup_date'];
$returndate = $_GET['return_date'];
//if($pickupdate >= $season_start_date_mid && $returndate <= $season_end_date_mid){
if($rental_days == 1){
return $GeneralPrice = $rent10;
$discount_price = 0;
}elseif($rental_days == 2){
return $GeneralPrice = $rent11;
$discount_price = 0;
}elseif($rental_days == 3){
return $GeneralPrice = $rent12;
$discount_price = 0;
}elseif($rental_days == 4){
return $GeneralPrice = $rent13;
$discount_price = 0;
}elseif($rental_days == 5){
return $GeneralPrice = $rent14;
$discount_price = 0;
}elseif($rental_days == 6){
return $GeneralPrice = $rent15;
$discount_price = 0;
}elseif($rental_days >= 7 && $rental_days <= 13){
return $GeneralPrice = $rent16;
$discount_price = 0;
}elseif($rental_days >= 14 && $rental_days <= 20){
return $GeneralPrice = $rent17;
$discount_price = 0;
}elseif($rental_days >= 21){
return $GeneralPrice = $rent18;
$discount_price = 0;
}
//}else {
// outofseason();
//}
}
//Season Mid_B
function Seasonmid_B() {
global $rental_days, $GeneralPrice, $discount_price, $season_start_date_mid_B, $season_end_date_mid_B, $rent19, $rent20, $rent21, $rent22, $rent23, $rent24, $rent25, $rent26, $rent27;
//Date calculator
$datetime1 = '2014-02-05';
$datetime2 = '2014-04-15';
$duration = 86400 ;
$days_dur = ceil(strtotime($datetime2)-strtotime($datetime1))/$duration;
//$season_start_date_mid = '05/03/2014';
//$season_end_date_mid = '15/03/2014';
$pickupdate = $_GET['pickup_date'];
$returndate = $_GET['return_date'];
//if($pickupdate >= $season_start_date_mid && $returndate <= $season_end_date_mid){
if($rental_days == 1){
return $GeneralPrice = $rent19;
$discount_price = 0;
}elseif($rental_days == 2){
return $GeneralPrice = $rent20;
$discount_price = 0;
}elseif($rental_days == 3){
return $GeneralPrice = $rent21;
$discount_price = 0;
}elseif($rental_days == 4){
return $GeneralPrice = $rent22;
$discount_price = 0;
}elseif($rental_days == 5){
return $GeneralPrice = $rent23;
$discount_price = 0;
}elseif($rental_days == 6){
return $GeneralPrice = $rent24;
$discount_price = 0;
}elseif($rental_days >= 7 && $rental_days <= 13){
return $GeneralPrice = $rent25;
$discount_price = 0;
}elseif($rental_days >= 14 && $rental_days <= 20){
return $GeneralPrice = $rent26;
$discount_price = 0;
}elseif($rental_days >= 21){
return $GeneralPrice = $rent27;
$discount_price = 0;
}
//}else {
// outofseason();
//}
}
//Season Mid_B
function SeasonHigh() {
global $rental_days, $GeneralPrice, $discount_price, $season_start_date_mid_high, $season_end_date_high, $rent28, $rent29, $rent30, $rent31, $rent32, $rent33, $rent34, $rent35, $rent36;
//Date calculator
$datetime1 = '2014-02-05';
$datetime2 = '2014-04-15';
$duration = 86400 ;
$days_dur = ceil(strtotime($datetime2)-strtotime($datetime1))/$duration;
//$season_start_date_mid = '05/03/2014';
//$season_end_date_mid = '15/03/2014';
$pickupdate = $_GET['pickup_date'];
$returndate = $_GET['return_date'];
//if($pickupdate >= $season_start_date_mid && $returndate <= $season_end_date_mid){
if($rental_days == 1){
return $GeneralPrice = $rent28;
$discount_price = 0;
}elseif($rental_days == 2){
return $GeneralPrice = $rent29;
$discount_price = 0;
}elseif($rental_days == 3){
return $GeneralPrice = $rent30;
$discount_price = 0;
}elseif($rental_days == 4){
return $GeneralPrice = $rent31;
$discount_price = 0;
}elseif($rental_days == 5){
return $GeneralPrice = $rent32;
$discount_price = 0;
}elseif($rental_days == 6){
return $GeneralPrice = $rent33;
$discount_price = 0;
}elseif($rental_days >= 7 && $rental_days <= 13){
return $GeneralPrice = $rent34;
$discount_price = 0;
}elseif($rental_days >= 14 && $rental_days <= 20){
return $GeneralPrice = $rent35;
$discount_price = 0;
}elseif($rental_days >= 21){
return $GeneralPrice = $rent36;
$discount_price = 0;
}
//}else {
// outofseason();
//}
}
//low
$season_start_date_low = (get_option('rc_settings_season_start_date_low'));
$season_end_date_low = (get_option('rc_settings_season_end_date_low'));
$season_start_date_low_convert = str_replace('/', '-', $season_start_date_low);
$season_low_start = date('Y-m-d', strtotime($season_start_date_low_convert));
$season_end_date_low_convert = str_replace('/', '-', $season_end_date_low);
$season_low_end = date('Y-m-d', strtotime($season_end_date_low_convert));
//mid
$season_start_date_mid = get_option('rc_settings_season_start_date_mid');
$season_end_date_mid = get_option('rc_settings_season_end_date_mid');
$season_start_date_mid_B = get_option('rc_settings_season_start_date_mid_B');
$season_end_date_mid_B = get_option('rc_settings_season_end_date_mid_B');
$season_start_date_mid_convert = str_replace('/', '-', $season_start_date_mid);
$season_mid_start = date('Y-m-d', strtotime($season_start_date_mid_convert));
$season_end_date_mid_convert = str_replace('/', '-', $season_end_date_mid);
$season_mid_end = date('Y-m-d', strtotime($season_end_date_mid_convert));
$season_start_date_mid_B_convert = str_replace('/', '-', $season_start_date_mid_B);
$season_mid_B_start = date('Y-m-d', strtotime($season_start_date_mid_B_convert));
$season_end_date_mid_B_convert = str_replace('/', '-', $season_end_date_mid_B);
$season_mid_B_end = date('Y-m-d', strtotime($season_end_date_mid_B_convert));
//High
$season_start_date_high = get_option('rc_settings_season_start_date_high');
$season_end_date_high = get_option('rc_settings_season_end_date_high');
$season_start_date_high_convert = str_replace('/', '-', $season_start_date_high);
$season_high_start = date('Y-m-d', strtotime($season_start_date_high_convert));
$season_end_date_high_convert = str_replace('/', '-', $season_end_date_high);
$season_high_end = date('Y-m-d', strtotime($season_end_date_high_convert));
//Date calculator
//$datetime1 = '01/01/2014';
//$datetime2 = '04/02/2014';
//$duration = 86400 ;
//$days_dur = ceil(strtotime($season_start_date_low)- strtotime($season_end_date_low))/$duration;
//Dates Conversion
$pickupdate_final = $_GET['pickup_date'];
$pickupdate_final_convert = str_replace('/', '-', $pickupdate_final);
$pickup_dates = date('Y-m-d', strtotime($pickupdate_final_convert));
$returndate_final = $_GET['return_date'];
$returndate_final_convert = str_replace('/', '-', $returndate_final);
$return_dates = date('Y-m-d', strtotime($returndate_final_convert));
//Conditions
if($pickup_dates >= $season_low_start && $return_dates <= $season_low_end){
Seasonlow();
echo "low <br />";
}elseif($pickup_dates >= $season_mid_start && $return_dates <= $season_mid_end){
Seasonmid();
echo "mid <br />";
}elseif($pickup_dates >= $season_mid_B_start && $return_dates <= $season_mid_B_end){
Seasonmid_B();
echo "mid_B <br />";
}elseif($pickup_dates >= $season_high_start && $return_dates <= $season_high_end){
SeasonHigh();
echo "High <br />";
}else{
outofseason();
echo "out <br />";
}
?>
回報將在功能中使用 –
破譯長碼!也許你可以提供一些有關正在調用什麼以及需要輸出什麼的細節。 –
在file2.php裏面我有5個函數,它們應該在一些x條件後改變file1.php中全局變量的值。 if/else condionts可以正常工作,並且功能之外的東西都可以成功迴應。問題在於5個函數中的所有值都不會在file1.php中回顯 – user3244910