• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP xml_encode函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中xml_encode函数的典型用法代码示例。如果您正苦于以下问题:PHP xml_encode函数的具体用法?PHP xml_encode怎么用?PHP xml_encode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了xml_encode函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: evt__form__enviar

    /**
     * Seguridad programada completamente
     */
    function evt__form__enviar($datos)
    {
        $carpeta = dirname(__FILE__);
        //--1- Arma el mensaje	(incluyendo los headers)
        $this->s__echo = $datos;
        $clave = xml_encode($datos['clave']);
        $valor = xml_encode($datos['valor']);
        $payload = <<<XML
<ns1:test xmlns:ns1="http://siu.edu.ar/toba_referencia/serv_pruebas">
\t<texto>{$clave} {$valor}</texto>
</ns1:test>
XML;
        $mensaje = new toba_servicio_web_mensaje($payload);
        //--2- Arma el servicio indicando certificado del server y clave privada del cliente
        $cert_server = ws_get_cert_from_file($carpeta . '/servidor.crt');
        $clave_privada = ws_get_key_from_file($carpeta . "/cliente.pkey");
        $cert_cliente = ws_get_cert_from_file($carpeta . "/cliente.crt");
        $seguridad = array("sign" => true, "encrypt" => true, "algorithmSuite" => "Basic256Rsa15", "securityTokenReference" => "IssuerSerial");
        $policy = new WSPolicy(array("security" => $seguridad));
        $security_token = new WSSecurityToken(array("privateKey" => $clave_privada, "receiverCertificate" => $cert_server, "certificate" => $cert_cliente));
        $opciones = array('to' => 'http://localhost/' . toba_recurso::url_proyecto() . '/servicios.php/serv_seguro_codigo', 'action' => 'http://siu.edu.ar/toba_referencia/serv_pruebas/test', 'policy' => $policy, 'securityToken' => $security_token);
        $servicio = toba::servicio_web('cli_seguro', $opciones);
        //-- 3 - Muestra la respuesta
        $respuesta = $servicio->request($mensaje);
        toba::notificacion()->info($respuesta->get_payload());
    }
开发者ID:emma5021,项目名称:toba,代码行数:29,代码来源:ci_cliente.php


示例2: xml_encode

function xml_encode($mixed, $domElement = null, $DOMDocument = null)
{
    if (is_null($DOMDocument)) {
        $DOMDocument = new DOMDocument();
        $DOMDocument->formatOutput = true;
        xml_encode($mixed, $DOMDocument, $DOMDocument);
        echo $DOMDocument->saveXML();
    } else {
        if (is_array($mixed)) {
            foreach ($mixed as $index => $mixedElement) {
                if (is_int($index)) {
                    if ($index === 0) {
                        $node = $domElement;
                    } else {
                        $node = $DOMDocument->createElement($domElement->tagName);
                        $domElement->parentNode->appendChild($node);
                    }
                } else {
                    $plural = $DOMDocument->createElement($index);
                    $domElement->appendChild($plural);
                    $node = $plural;
                    if (!(rtrim($index, 's') === $index)) {
                        $singular = $DOMDocument->createElement(rtrim($index, 's'));
                        $plural->appendChild($singular);
                        $node = $singular;
                    }
                }
                xml_encode($mixedElement, $node, $DOMDocument);
            }
        } else {
            $domElement->appendChild($DOMDocument->createTextNode($mixed));
        }
    }
}
开发者ID:sisjosex,项目名称:phpadmin,代码行数:34,代码来源:util.php


示例3: ajaxReturn

 /**
  * Ajax方式返回数据到客户端
  * @access protected
  * @param mixed $data 要返回的数据
  * @param String $type AJAX返回数据格式
  * @return void
  */
 protected function ajaxReturn($data, $type = '')
 {
     if (empty($type)) {
         $type = C('DEFAULT_AJAX_RETURN');
     }
     switch (strtoupper($type)) {
         case 'JSON':
             // 返回JSON数据格式到客户端 包含状态信息
             header('Content-Type:application/json; charset=utf-8');
             exit(json_encode($data));
         case 'XML':
             // 返回xml格式数据
             header('Content-Type:text/xml; charset=utf-8');
             exit(xml_encode($data));
         case 'JSONP':
             // 返回JSON数据格式到客户端 包含状态信息
             header('Content-Type:application/json; charset=utf-8');
             $handler = isset($_GET[C('VAR_JSONP_HANDLER')]) ? $_GET[C('VAR_JSONP_HANDLER')] : C('DEFAULT_JSONP_HANDLER');
             exit($handler . '(' . json_encode($data) . ');');
         case 'EVAL':
             // 返回可执行的js脚本
             header('Content-Type:text/html; charset=utf-8');
             exit($data);
     }
 }
开发者ID:pengshizhong,项目名称:movie-shop,代码行数:32,代码来源:Controller.class.php


示例4: evt__form_adjunto__enviar

    function evt__form_adjunto__enviar($datos)
    {
        //--1 -Guarda el archivo en un temporal
        if (isset($datos['adjunto'])) {
            $this->s__adjunto['archivo'] = $datos['adjunto']['name'];
            $img = toba::proyecto()->get_www_temp($this->s__adjunto['archivo']);
            // Mover los archivos subidos al servidor del directorio temporal PHP a uno propio.
            move_uploaded_file($datos['adjunto']['tmp_name'], $img['path']);
        }
        $this->s__adjunto['texto'] = xml_encode($datos['texto']);
        //--2 -Arma el mensaje
        $payload = <<<XML
<ns1:upload xmlns:ns1="http://siu.edu.ar/toba_referencia/serv_pruebas">
\t<texto>{$this->s__adjunto['texto']}</texto>
    <ns1:fileName>{$this->s__adjunto['archivo']}</ns1:fileName>
\t<ns1:image xmlmime:contentType="image/png" xmlns:xmlmime="http://www.w3.org/2004/06/xmlmime">
    \t<xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:myid1"></xop:Include>
\t</ns1:image>
</ns1:upload>
XML;
        //--3 -Pide el servicio
        $opciones = array('to' => 'http://localhost/' . toba_recurso::url_proyecto() . '/servicios.php/serv_sin_seguridad');
        $servicio = toba::servicio_web('cli_sin_seguridad', $opciones);
        $imagen = toba::proyecto()->get_www_temp($this->s__adjunto['archivo']);
        $imagen_contenido = file_get_contents($imagen['path']);
        $opciones = array('attachments' => array('myid1' => $imagen_contenido));
        $mensaje = new toba_servicio_web_mensaje($payload, $opciones);
        $respuesta = $servicio->request($mensaje);
        //--4 - Guarda la respuesta en un temporal
        $this->adjunto_respuesta = toba::proyecto()->get_www_temp('salida.png');
        file_put_contents($this->adjunto_respuesta['path'], current($respuesta->wsf()->attachments));
    }
开发者ID:emma5021,项目名称:toba,代码行数:32,代码来源:ci_cliente.php


示例5: ajaxReturn

 public function ajaxReturn($data, $type = "")
 {
     if (empty($type)) {
         $type = "json";
     }
     switch (strtoupper($type)) {
         case "JSON":
             header("Content-Type:application/json; charset=" . CHARSET);
             exit(CJSON::encode($data));
             break;
         case "XML":
             header("Content-Type:text/xml; charset=" . CHARSET);
             exit(xml_encode($data));
             break;
         case "JSONP":
             header("Content-Type:text/html; charset=" . CHARSET);
             $handler = isset($_GET["callback"]) ? $_GET["callback"] : self::DEFAULT_JSONP_HANDLER;
             exit($handler . "(" . (!empty($data) ? CJSON::encode($data) : "") . ");");
             break;
         case "EVAL":
             header("Content-Type:text/html; charset=" . CHARSET);
             exit($data);
             break;
         default:
             exit($data);
             break;
     }
 }
开发者ID:AxelPanda,项目名称:ibos,代码行数:28,代码来源:ICController.php


示例6: ajaxReturn

 /**
  * Ajax方式返回数据到客户端
  * @access protected
  * @param mixed $data 要返回的数据
  * @param String $type AJAX返回数据格式
  * @return void
  */
 protected function ajaxReturn($data, $type = '', $json_option = 0)
 {
     $data['referer'] = $data['url'] ? $data['url'] : "";
     $data['state'] = $data['status'] ? "success" : "fail";
     if (empty($type)) {
         $type = C('DEFAULT_AJAX_RETURN');
     }
     switch (strtoupper($type)) {
         case 'JSON':
             // 返回JSON数据格式到客户端 包含状态信息
             header('Content-Type:application/json; charset=utf-8');
             exit(json_encode($data, $json_option));
         case 'XML':
             // 返回xml格式数据
             header('Content-Type:text/xml; charset=utf-8');
             exit(xml_encode($data));
         case 'JSONP':
             // 返回JSON数据格式到客户端 包含状态信息
             header('Content-Type:application/json; charset=utf-8');
             $handler = isset($_GET[C('VAR_JSONP_HANDLER')]) ? $_GET[C('VAR_JSONP_HANDLER')] : C('DEFAULT_JSONP_HANDLER');
             exit($handler . '(' . json_encode($data, $json_option) . ');');
         case 'EVAL':
             // 返回可执行的js脚本
             header('Content-Type:text/html; charset=utf-8');
             exit($data);
         case 'AJAX_UPLOAD':
             // 返回JSON数据格式到客户端 包含状态信息
             header('Content-Type:text/html; charset=utf-8');
             exit(json_encode($data, $json_option));
         default:
             // 用于扩展其他返回格式数据
             Hook::listen('ajax_return', $data);
     }
 }
开发者ID:lvxiaolin,项目名称:thinkcfm,代码行数:41,代码来源:AppframeController.class.php


示例7: mtReturn

 public function mtReturn($status, $info, $navTabId = "", $closeCurrent = true)
 {
     $result = array();
     $result['statusCode'] = $status;
     $result['message'] = $info;
     $result['tabid'] = $navTabId . '/index';
     $result['forward'] = '';
     $result['forwardConfirm'] = '';
     $result['closeCurrent'] = $closeCurrent;
     if (empty($type)) {
         $type = C('DEFAULT_AJAX_RETURN');
     }
     if (strtoupper($type) == 'JSON') {
         // 返回JSON数据格式到客户端 包含状态信息
         header("Content-Type:text/html; charset=utf-8");
         exit(json_encode($result));
     } elseif (strtoupper($type) == 'XML') {
         // 返回xml格式数据
         header("Content-Type:text/xml; charset=utf-8");
         exit(xml_encode($result));
     } elseif (strtoupper($type) == 'EVAL') {
         // 返回可执行的js脚本
         header("Content-Type:text/html; charset=utf-8");
         exit($data);
     } else {
         // TODO 增加其它格式
     }
 }
开发者ID:mcxzyang,项目名称:vipclub,代码行数:28,代码来源:CommonController.class.php


示例8: op__test

    /**
     * Responde exactamente con la misma cadena enviada
     * @param string $texto texto a repetir
     * (maps to the xs:string XML schema type )
     * @return string $texto total price
     *(maps to the xs:string XML schema type )
     */
    function op__test(toba_servicio_web_mensaje $mensaje)
    {
        $xml = new SimpleXMLElement($mensaje->get_payload());
        $texto = xml_encode((string) $xml->texto);
        $payload = <<<XML
<ns1:eco xmlns:ns1="http://siu.edu.ar/toba_referencia/pruebas">
\t<texto>Respuesta: {$texto}</texto>
</ns1:eco>
XML;
        return new toba_servicio_web_mensaje($payload);
    }
开发者ID:emma5021,项目名称:toba,代码行数:18,代码来源:servicio.php


示例9: xml_encode

/**
 * Converte um objeto ou um array em uma string XML
 * @param	mixed	$data		dados a serem convertidos em XML
 * @return	string				retorna uma string XML
 */
function xml_encode($data)
{
    if (!is_array($data) && !is_object($data)) {
        return $data;
    }
    $encoded = "\n";
    foreach ($data as $k => $d) {
        $e = is_string($k) ? $k : 'n';
        $encoded .= "\t<" . $e . ">" . xml_encode($d) . "</" . $e . ">\n";
    }
    return $encoded . "";
}
开发者ID:nylmarcos,项目名称:estagio,代码行数:17,代码来源:functions.php


示例10: ResponsetoApp

 public static function ResponsetoApp($retcode, $msg_body)
 {
     global $req_token;
     // 授权码
     global $au_token;
     // 动态码
     global $req_version;
     // 版本号
     global $req_bkenv;
     // 银联环境
     global $req_time;
     global $api_name;
     global $api_name_func;
     global $reqcontext;
     global $authorid;
     global $authortruename;
     global $g_sdcrid;
     $arr_retmsg = array('0' => '成功', '500' => '执行代码错误', '600' => '客户端调用错误', '700' => '数据库出错', '900' => '引用延迟', '800' => '银行卡交易代码请求错误,请填写正确的银行卡信息', '400' => '商户权限不足', '300' => '停留时间太长,请重新登录!', '404' => '请求功能不存在', '505' => '用户信息已被异地篡改,请重新登录', '200' => '自定义错误', '100' => '商户权限不足');
     if ($retcode != '200' && $retcode != '0' && $retcode != '300') {
         $retmsg = $arr_retmsg[$retcode];
     } else {
         if ($retcode != '700' or $retcode != '800') {
             $retmsg = $msg_body['msgbody']['message'];
         }
     }
     if ($g_sdcrid >= '100') {
         $req_bkenv = '01';
         //测试环境
     } else {
         $req_bkenv = '00';
         //正式环境
     }
     $msg_header = array('msgheader' => array('au_token' => $au_token, 'req_token' => $req_token, 'req_bkenv' => $req_bkenv, 'retinfo' => array('rettype' => $retcode, 'retcode' => $retcode, 'retmsg' => $retmsg)));
     $Responsecontext['operation_response'] = array_merge($msg_header, $msg_body);
     $rqvalue = xml_encode($Responsecontext, 'utf-8');
     //$returnval ="";
     $reqcry = TfbAuthRequest::getReqDatatype($reqcontext);
     //请求的数据流
     $TfbAuthRequest = new TfbAuthRequest();
     if ($reqcry == 'E') {
         $returnval = $TfbAuthRequest->desEncryptStr($rqvalue);
     } else {
         $returnval = $rqvalue;
     }
     $authorid = $authorid + 0;
     $file = "../../" . CONST_LOGDIR . "/" . date('md') . "-" . $authortruename . "log" . ".txt";
     $filehandle = fopen($file, "a");
     fwrite($filehandle, "\r\n======响应内容:\r\n" . $rqvalue . "\r\n\r\n" . $returnval . "\r\n\r\n<!--------------结束------------>\r\n\r\n\r\n");
     fclose($filehandle);
     return $returnval;
 }
开发者ID:Xiaoyuyexi,项目名称:client-server,代码行数:51,代码来源:tfbxmlResponse.class.php


示例11: test_servicio_eco

    function test_servicio_eco()
    {
        $mensaje = xml_encode("Holá Mundo");
        $payload = <<<XML
<ns1:eco xmlns:ns1="http://siu.edu.ar/toba_referencia/serv_pruebas">
\t<texto>{$mensaje}</texto>
</ns1:eco>
XML;
        $opciones = array('to' => 'http://localhost/' . toba_recurso::url_proyecto($this->get_proyecto()) . '/servicios.php/serv_sin_seguridad');
        $servicio = toba::servicio_web('cli_sin_seguridad', $opciones);
        $mensaje = $servicio->request(new toba_servicio_web_mensaje($payload));
        $xml = new SimpleXMLElement($mensaje->get_payload());
        $this->AssertEqual(xml_decode((string) $xml->texto), "Respuesta: Holá Mundo");
    }
开发者ID:emma5021,项目名称:toba,代码行数:14,代码来源:test_servicio_web.php


示例12: _parseWidgets

 function _parseWidgets()
 {
     $widget_path = LIB_PATH . 'Widgets/';
     $dirs = glob($widget_path . '*', GLOB_ONLYDIR);
     if ($dirs) {
         $xml = array();
         foreach ($dirs as $key => $row) {
             $info_file = $row . '/info.php';
             if (file_exists($info_file)) {
                 $xml[basename($row)]['info'] = (include $info_file);
             }
         }
         file_put_contents($widget_path . 'widgets.xml', xml_encode($xml));
         return $xml;
     }
 }
开发者ID:dalinhuang,项目名称:concourse,代码行数:16,代码来源:WidgetsAction.class.php


示例13: response

 /**
  * 服务器响应
  *
  * @param  integer $errno  错误码
  * @param  string  $errmsg 提示信息
  * @param  mixed $data   数据
  * @param  string  $type   格式类型 (json,xml)
  * @return int
  */
 public static function response($errno = 0, $errmsg = 'ok', $data = null, $type = 'json')
 {
     $res = array("errno" => $errno, 'errmsg' => $errmsg);
     $data = array_merge($res, array('data' => $data));
     switch ($type) {
         case 'xml':
             echo xml_encode($data, 'root');
             break;
         case 'json':
             echo json_encode($data);
             break;
         default:
             exit("Invalid format type.");
             break;
     }
     return $errno;
 }
开发者ID:jianzi0307,项目名称:RunCMS,代码行数:26,代码来源:Util.class.php


示例14: ajaxReturn

 /**
  * Ajax方式返回数据到客户端
  * @access protected
  * @param mixed $data 要返回的数据
  * @param String $type AJAX返回数据格式
  * @return void
  */
 protected function ajaxReturn($data, $type = '')
 {
     if (func_num_args() > 2) {
         // 兼容3.0之前用法
         $args = func_get_args();
         array_shift($args);
         $info = array();
         $info['data'] = $data;
         $info['info'] = array_shift($args);
         $info['status'] = array_shift($args);
         $data = $info;
         $type = $args ? array_shift($args) : '';
     }
     //返回格式
     $return = array("referer" => $data['url'] ? $data['url'] : "", "state" => $data['status'] ? "success" : "fail", "info" => $data['info'], "status" => $data['status'], "data" => $data['data']);
     if (empty($type)) {
         $type = C('DEFAULT_AJAX_RETURN');
     }
     switch (strtoupper($type)) {
         case 'JSON':
             // 返回JSON数据格式到客户端 包含状态信息
             header('Content-Type:application/json; charset=utf-8');
             exit(json_encode($return));
         case 'XML':
             // 返回xml格式数据
             header('Content-Type:text/xml; charset=utf-8');
             exit(xml_encode($return));
         case 'JSONP':
             // 返回JSON数据格式到客户端 包含状态信息
             header('Content-Type:application/json; charset=utf-8');
             $handler = isset($_GET[C('VAR_JSONP_HANDLER')]) ? $_GET[C('VAR_JSONP_HANDLER')] : C('DEFAULT_JSONP_HANDLER');
             exit($handler . '(' . json_encode($return) . ');');
         case 'EVAL':
             // 返回可执行的js脚本
             header('Content-Type:text/html; charset=utf-8');
             exit($return);
         case 'AJAX_UPLOAD':
             // 返回JSON数据格式到客户端 包含状态信息
             header('Content-Type:text/html; charset=utf-8');
             exit(json_encode($return));
         default:
             // 用于扩展其他返回格式数据
             tag('ajax_return', $return);
     }
 }
开发者ID:it114,项目名称:public,代码行数:52,代码来源:AppframeAction.class.php


示例15: xml_encode

function xml_encode($name, $content = '', $indent = '')
{
    // Check for entity name validity
    if (empty($content)) {
        return $indent . "<{$name}/>\n";
    } else {
        if (is_array($content)) {
            $ent_block = $indent . "<{$name}>\n";
            foreach ($content as $k => $v) {
                $ent_block .= xml_encode($k, $v, $indent . "\t");
            }
            $ent_block .= $indent . "</{$name}>\n";
            return $ent_block;
        } else {
            return $indent . "<{$name}>" . htmlspecialchars($content, ENT_QUOTES) . "</{$name}>\n";
        }
    }
}
开发者ID:nyimbi,项目名称:legalcase,代码行数:18,代码来源:inc_xml.php


示例16: run

 public function run($types, $virtual_path)
 {
     $result = array();
     if ($this->setting_list['caching'] && $this->get_cache_handler != NULL && ($result = $this->get_cache_handler->__invoke(base64_encode(serialize($_REQUEST)), $this->setting_list['cache_time']))) {
     } else {
         $types = explode(',', strtoupper($types));
         foreach ($types as $type) {
             if (isset($this->list[$type])) {
                 foreach ($this->list[$type] as $path => $callback) {
                     if (preg_match("#^" . $path . "\$#simU", $virtual_path, $x1)) {
                         if (is_callable($callback)) {
                             //header($type . " 200 OK");
                             if (phpversion() >= 5.3) {
                                 $result = $callback($x1);
                             } else {
                                 call_user_func_array($callback, array($x1));
                             }
                         }
                     }
                 }
             }
         }
         if (!$result) {
             //header($type . " 404 Not Found");
             $result = "-1";
         }
         if ($this->set_cache_handler) {
             $this->set_cache_handler->__invoke(base64_encode(serialize($_REQUEST)), $result);
         }
     }
     if ($this->format == "XML") {
         header("Content-Type: text/xml");
         echo xml_encode($result, "response");
     } else {
         if ($this->format == "JSON") {
             header("Content-Type: text/plain");
             if (isset($_GET['callback'])) {
                 echo $_GET['callback'] . '(' . json_encode($result) . ');';
             } else {
                 echo json_encode($result);
             }
         }
     }
 }
开发者ID:stokegames,项目名称:mmo,代码行数:44,代码来源:rest.php


示例17: ajaxReturn

 /**
  * ajax返回
  * Enter description here ...
  * @param unknown_type $data
  * @param unknown_type $info
  * @param unknown_type $type
  */
 public function ajaxReturn($data = array(), $status, $type = "xml")
 {
     if (array_key_exists("title", $data)) {
         $datas["title"] = $data["title"];
     }
     if (array_key_exists("message", $data)) {
         $datas["message"] = $data["message"];
     }
     $datas["status"] = $status;
     if ($type == "json") {
         //输出json
         header("Content-Type:text/html; charset=utf-8");
         exit(json_encode($datas));
     } elseif ($type == "xml") {
         //输出xml
         header("Content-Type:text/xml; charset=utf-8");
         exit(xml_encode($datas));
     }
 }
开发者ID:captaim,项目名称:cleverPHP,代码行数:26,代码来源:Controller.class.php


示例18: mtReturn

 public function mtReturn($status, $info, $navTabId = '', $callbackType = 'closeCurrent', $forwardUrl = '', $rel = '', $type = '')
 {
     // 保证AJAX返回后也能保存日志
     $result = array();
     if ($navTabId == '') {
         $navTabId = $_REQUEST['navTabId'];
     }
     if ($status == '200') {
         $this->sysLogs('', $info);
     }
     if ($status == '201') {
         $status = 200;
     }
     $result['statusCode'] = $status;
     // dwzjs
     $result['navTabId'] = $navTabId;
     // dwzjs
     $result['callbackType'] = $callbackType;
     // dwzjs
     $result['message'] = $info;
     // dwzjs
     $result['forwardUrl'] = $forwardUrl;
     $result['rel'] = $rel;
     if (empty($type)) {
         $type = C('DEFAULT_AJAX_RETURN');
     }
     if (strtoupper($type) == 'JSON') {
         // 返回JSON数据格式到客户端 包含状态信息
         header("Content-Type:text/html; charset=utf-8");
         exit(json_encode($result));
     } elseif (strtoupper($type) == 'XML') {
         // 返回xml格式数据
         header("Content-Type:text/xml; charset=utf-8");
         exit(xml_encode($result));
     } elseif (strtoupper($type) == 'EVAL') {
         // 返回可执行的js脚本
         header("Content-Type:text/html; charset=utf-8");
         exit($data);
     } else {
         // TODO 增加其它格式
     }
 }
开发者ID:Willshon,项目名称:OLCS,代码行数:42,代码来源:PublicController.class.php


示例19: mtReturn

 protected function mtReturn($status, $info, $navTabId = "", $closeCurrent = true)
 {
     // 写入日志
     // $udata['id']=session('uid');
     $udata['update_time'] = time();
     $Rs = M("user")->save($udata);
     // $dat['username'] = session('username');
     $dat['content'] = $info;
     $dat['os'] = $_SERVER['HTTP_USER_AGENT'];
     $dat['url'] = U();
     $dat['addtime'] = date("Y-m-d H:i:s", time());
     $dat['ip'] = get_client_ip();
     M("log")->add($dat);
     // 回调
     $result = array();
     $result['statusCode'] = $status;
     $result['message'] = $info;
     $result['tabid'] = strtolower($navTabId) . '/index';
     $result['forward'] = '';
     $result['forwardConfirm'] = '';
     $result['closeCurrent'] = $closeCurrent;
     if (empty($type)) {
         $type = C('DEFAULT_AJAX_RETURN');
         // var_dump($type);
     }
     if (strtoupper($type) == 'JSON') {
         // 返回JSON数据格式到客户端 包含状态信息
         header("Content-Type:text/html; charset=utf-8");
         exit(json_encode($result));
     } elseif (strtoupper($type) == 'XML') {
         // 返回xml格式数据
         header("Content-Type:text/xml; charset=utf-8");
         exit(xml_encode($result));
     } elseif (strtoupper($type) == 'EVAL') {
         // 返回可执行的js脚本
         header("Content-Type:text/html; charset=utf-8");
         exit($data);
     } else {
         // TODO 增加其它格式
     }
 }
开发者ID:siimanager,项目名称:sii,代码行数:41,代码来源:CommonController.class.php


示例20: encodeData

 /**
  * 编码数据
  * @access protected
  * @param mixed $data 要返回的数据
  * @param String $type 返回类型 JSON XML
  * @return string
  */
 protected function encodeData($data, $type = '')
 {
     if ('json' == $type) {
         // 返回JSON数据格式到客户端 包含状态信息
         $data = json_encode($data);
         if (I('get.jsonpcallback')) {
             $data = I('get.jsonpcallback') . '(' . $data . ')';
         }
         if (I('get.fileiframetransport', '')) {
             $data = I('get.jsonpcallback') . '<textarea data-type="application/json">' . "\n" . $data . "\n" . '</textarea>';
         }
     } elseif ('xml' == $type) {
         // 返回xml格式数据
         $data = xml_encode($data);
         //        }elseif('php'==$type){
         //            $data = serialize($data);
     }
     // 默认直接输出
     $this->setContentType($type);
     //header('Content-Length: ' . strlen($data));
     return $data;
 }
开发者ID:zsefvlol,项目名称:threedegrees,代码行数:29,代码来源:RestCommonController.class.php



注:本文中的xml_encode函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP xml_error函数代码示例发布时间:2022-05-23
下一篇:
PHP xml_convert函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap