I developed a web application with cakephp locally on Windows XP using xampp and everything works fine. Today I deployed it to CentOS and Ubuntu Server, and I had a problem. What happens is that the tab space is displayed along with my information. Let's say I make an ajax call that should return OK , what is returned is " OK" , more precisely (0x09)OK
I do not know where this tab comes from. I have reduced my code to the maximum, and still get it.
controller
public function sendcomment() { $this->layout = 'ajax'; $this->set('ret', 'OK'); }
View
<?php echo $ret; ?>
Even if I do not use the view file and the exit information directly on the layout, the tab still exists:
controller
public function sendcomment() { $this->layout = 'testlayout'; }
testlayout.ctp
OK
This happens in all actions, regardless of what a layout is.
Did anyone go through this and find out what could happen? All my files are encoded in UTF-8 without specification, and they work fine with XAMPP on Windows.
- Change:
Ok, some said it was a config problem, I really don't know. However, trying to find where the tab came from, I started placing echoes in the main files and moving on and on until I finally get to where the tab is. Regarding index.php from the cake web peel, if I put echo 'a' before the dispatch() method, my result is a(0x09)OK . So the tab really comes from the cake.
Now here is the problem, looking at the results of several tests, I finally got stuck, and this did not lead to anything.
Now I am on (CakeRoot)/lib/Cake/Routing/Dispatcher.php . Here we have the following method:
protected function _loadController($request) { $pluginName = $pluginPath = $controller = null; if (!empty($request->params['plugin'])) { $pluginName = $controller = Inflector::camelize($request->params['plugin']); $pluginPath = $pluginName . '.'; } if (!empty($request->params['controller'])) { $controller = Inflector::camelize($request->params['controller']); } if ($pluginPath . $controller) { $class = $controller . 'Controller'; App::uses('AppController', 'Controller'); App::uses($pluginName . 'AppController', $pluginPath . 'Controller'); App::uses($class, $pluginPath . 'Controller'); if (class_exists($class)) { return $class; } } return false; }
I am exactly in this part:
App::uses($class, $pluginPath . 'Controller'); if (class_exists($class)) { return $class; }
Now here are the tests if I put echo right before the if, for example:
App::uses($class, $pluginPath . 'Controller'); echo 'a'; if (class_exists($class)) { return $class; }
My output will be a(0x09)OK . However, if I put my echo right inside, if so:
App::uses($class, $pluginPath . 'Controller'); if (class_exists($class)) { echo 'a'; return $class; }
My output will be (0x09)aOK . The only thing that comes to my mind is that class_exists() performs an echo tab. But that just doesn't make any sense. For testing purposes, I did the following:
App::uses($class, $pluginPath . 'Controller'); if (TRUE) { return $class; }
Still, the tab is displayed. Even worse, if I do if == TRUE like this, regardless of whether the echo is “a” before if or to the right inside the if, the output will always be a(0x09)OK .
What the hell is going on here?