问题
echo in codeigniter controller is not working.. Is there any setting in config to enable echo in codeigniter. All other files are working except those which are having echo in controllers.
<?php
class Blog extends CI_Controller {
public function index()
{
echo 'Hello World!';
}
}
Basically iam testing jquery and condeigniter sample script given in http://www.ryantetek.com/2009/12/how-to-create-a-simple-ajax-post-in-codeigniter-using-jquery. but i found script is not working because echo statement in controller. please help me.
error: "This webpage is not available"..
回答1:
I have face the same problem but only in mac browsers and i fixed that with this one
In your ./application/config/config.php file check $config['compressed_output'] if it set to true then make it false as some browsers does not support compressed output.
回答2:
Your code is correct. You are likely accessing the wrong path. Do not load the controller directly, because CodeIgniter does freaky stuff with URLs--instead, load a URL similar to the following:
http://yoursite.com/code_igniter_path/index.php/blog/index
Good luck!
来源:https://stackoverflow.com/questions/10520423/echo-in-codeigniter-controller-is-not-working