我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

在Nette PHP框架中不使用模板返回字符串

What is the best way to return a json string or a simple text on screen in nette php framework without loading the template?

You can use method sendJson($data) in your presenter.

function renderDefault()
{
    $data = ['hello' => 'world'];
    $this->sendJson($data);
}

Will output {"hello":"world"} with application/json Content-Type

近期文章

  • WAMPServer安装 - phpMyAdmin登录时出错 - 错误#1193
  • HTML表单不从输入发送UTF-8字母。 PHP,MOODLE
  • 使用Codeigniter使用segment和URI获取变量[关闭]
  • 如何使用Prestashop 1.6.1复制现有订单(核心,php)
  • 将移动用户重定向到移动网址
  • 为什么控制器不渲染树枝模板
  • 适当的SQL语法,用于在PHP中使用“绑定值”时仅插入唯一条目
  • 读取计算值时出现PHPExcel错误
  • PHP在三元组中使用empty,isset或is_null
  • 应该在简单实体中测试什么(TDD)?
  • 使用Javascript在没有PHP的情况下将数据插入Mysql
  • 如何解决laravel 5.3中RouteCollection.php中的MethodNotAllowedHttpException? [重复]
  • 在尝试从中检索表单数据时,如何将php应用于6个单独的选择元素?
  • PHP中的PHP if语句
  • PHP中的请求错误中未检测到会话令牌(JWT)或API密钥
  • 任何人都知道如何在mysql中存储图像并使用angular和php显示回来?
  • 定义与否wp_ajax_nopriv
  • 将变量从PHP传递给ubuntu
  • 将MySQL模式添加到MySQL Workbench?
  • 通过PHPMailer()发送的HTML2PDF输出

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华