Php 将十六进制作为参数传递失败

Php 将十六进制作为参数传递失败,php,Php,我试图像这样从香草php调用codeigniter方法 get.php <?php $options = array( 'vars' => array( 'one' => 'hello', 'two' => 'world' ) ); function strToHex($string){ $hex = ''; for ($i=0; $i<strlen($string); $i++){

我试图像这样从香草php调用codeigniter方法

get.php

<?php
$options = array(
    'vars' => array(
        'one'   => 'hello',
        'two'   => 'world'
    )
);
function strToHex($string){
    $hex = '';
    for ($i=0; $i<strlen($string); $i++){
        $ord = ord($string[$i]);
        $hexCode = dechex($ord);
        $hex .= substr('0'.$hexCode, -2);
    }
    return strToUpper($hex);
}


$p1 = $options["vars"]["one"];
$p2 = $options["vars"]["two"];

$en = serialize($options);
$tohex = strToHex($en);

try{
echo file_get_contents("http://localhost/app/welcome/entry/".$tohex);
$json = file_get_contents("http://localhost/app/welcome/entry/".$tohex,true);
if ($json === false) {
    echo 'Request with id'.' '.rand(5667789,790637738).' '.'was not successful.This incident was logged.';
}
}
catch(Exception $e){
echo $e->getMessage();
}

?>

这是我的codeigniter方法

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Welcome extends CI_Controller {
    public function index()
    {
        $this->load->view('welcome_message');
    }
    public function hexToStr($hex){
    $string='';
    for ($i=0; $i < strlen($hex)-1; $i+=2){
        $string .= chr(hexdec($hex[$i].$hex[$i+1]));
    }
    return $string;
    }
    public function entry($in){
    $in = $this->uri->segment(3);
    $arr = hexToStr($in);
    $array = unserialize($arr);
    print_r($array);
    /**
    $p1 = $arr["vars"]["one"];
    $p2 = $arr["vars"]["two"];
    redirect('welcome/'.$p1/$p2);
    */
    }

    public function hello(){
    echo 'connected';
    }
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */

我使用了
hex2bin
函数,现在我的代码按预期工作

public function entry($in){
    $in = $this->uri->segment(3);
    $arr = hex2bin($in);
    $array = unserialize($arr);
    $p1 = $arr["vars"]["one"];
    //print_r($array);
    $p1 = $array["vars"]["one"];
    echo $p1;
    /**
    $p1 = $arr["vars"]["one"];
    $p2 = $arr["vars"]["two"];
    redirect('welcome/'.$p1/$p2);
    */
    }

如果打开
http://localhost/app/welcome/entry/
在浏览器中?不,当我打开
http://localhost/app/welcome/entry/613A313A7B733A343A2276617273223B613A323A7B733A333A226F6E65223B733A353A2268656C6C6F223B733A333A2274776F223B733A353A22776F726C64223B7D7D
我什么也看不见,所以如果什么都没有,那就什么都没有了。为什么要使用另一个链接?您的CI实例安装在哪里<代码>应用程序
Qplatform
?首先准备好浏览器。当然,你是如此聪明和复杂。我想不通你的想法:-)我只是想帮你。如果您的CI应用程序没有为浏览器生成预期的响应,您如何继续?这就像你想开车,即使你的引擎不工作。你必须先启动引擎。我并不怀疑你的技能。我只是说。如果你弄错了,我很抱歉。我已经删除了评论以避免任何混乱。我道歉并感谢你的帮助。