0

大家好我有问题这个代码必须在wordpress后端提供文件下载但是它给了我jeson代码任何人都可以在这里帮助我的代码

         $oprion_name_theme =  $this->theme->options['theme_options_field'];

         $shadyssa_options  =  $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options WHERE option_name like '%$oprion_name_theme%'");

         $resul = $shadyssa_options[0] ;

         $result = (array) $resul ;
         ob_start() ;
         $output =   json_encode($result) ;
         header("Content-type: application/octet-stream") ;
         header("Content-Disposition: attachment; filename='test.json'");
         header( 'Content-Length: ' . strlen( $output ) );   
         echo $output;

提前致谢

4

1 回答 1

0

这里的错字:

$result = (array) $resul ;

你想要一个文件下载?但你输出为 json

 header("Content-type: application/octet-stream") ;
 header("Content-Disposition: attachment; filename='test.json'");

你想要的是哪一个?

于 2012-12-18T10:32:19.543 回答