CakePHP 2.x sanitize utils

Importing core files has changed in CakePHP 2.x, which means you have to change App::import('Sanitize'); to App::uses('Sanitize', 'Utility');. Also remove the $uses statement, it’s for loading models and Sanitize is not a model.

With those modifications, your snippet will look like:

1
2
3
4
5
6
7
8
App::uses('Sanitize', 'Utility');
class MyController extends AppController
{
function Foo()
{
$test = Sanitize::paranoid($data);
}
}

 

坚持原创技术分享,您的支持将鼓励我继续创作!