2

ERROR:When i print $myconfig array on config.php then it's print a different value.focus on only [main_url] its value is changed when run on config.php

myconfig.php

<?php
        $base_url = $_POST['base_url'];
        if($base_url == ""){
            $url=((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "https" : "http"). "://". @$_SERVER['HTTP_HOST']."/football/responsive_filemanager";
        }else{
            $url=$base_url;
        }   
        echo $base_url."</br>";
        echo $url;

        $myconfig=array(

            'main_url'=>$url,

            'upload_dir' => '/source/',

            'current_path' => '../source/',

            'thumbs_base_path' => '../thumbs/',

            'multiple_selection' => false,

            'multiple_selection_action_button' => false
        );
        //return $myconfig;
        /*echo "<pre>";*/
        //print_r($myconfig);
    ?>

Output of myconfig.php enter image description here

config.php

<?php
     include("../../myconfig.php");
     print_r($myconfig);
     exit();
?>

Output of config.php enter image description here

6
  • Did you try changing == to !==? Why are you confirming $base_url value? Commented Jul 18, 2018 at 10:16
  • Yes i try all things. I confirming $base_url because its value come through ajax or jquery and some time its blank.So i confirming $base_url value Commented Jul 18, 2018 at 10:18
  • there is something wrong because if($base_url == "") are always false Commented Jul 18, 2018 at 10:21
  • I tested both codes.I don't have any problem with them.maybe you put myconfig.php somewhere else and config.php is reading another(maybe test file) file Commented Jul 18, 2018 at 10:23
  • Yes thats the error how can i solve bro please help me out i stuck in this problem @Rainmx93 Commented Jul 18, 2018 at 10:24

1 Answer 1

1

I think your condition is wrong. You are setting the value to $base_url before your condition, so it will always go in else statement. so if I uderstood your problem your condition should be changed from $base_url == "" to $base_url !== ""

   if($base_url !== ""){
        $url=((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "https" : "http"). "://". @$_SERVER['HTTP_HOST']."/football/responsive_filemanager";
    }
else{
        $url=$base_url;
    }   
Sign up to request clarification or add additional context in comments.

1 Comment

$base_url value is coming through ajax or jquery

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.