Banner image

Passing an array to js from PHP

This code line can be inserted at the top of a view file. It will add a document.ready function() js code line that creates a javascript array and passes it into a javascript function.
The data passed is only an example of how to pass data this way.

$this->addReadyCode("params={uid:'2',timestamp:'43543224333',url: '/home' };setLogin(params);");

Use in document.ready setJSxx() functions

This method is more secure than leaving information in visible DOM elements for js to pick up
iBiscuits LOGO

380 memberDB.php INSERT INTO et_page_visits ( vuid,vpage,vreferrer,vtime,vlang,vagent,vbot,vversion,vguest,vip) VALUES ( "1","http://englishtap.com/help/array2js","Unknown","1534483949","","CCBot/2.0 (https://commoncrawl.org/faq/)","","biscuits-12y","","54.161.49.216") ON DUPLICATE KEY UPDATE vuid = "1" ,vpage = "http://englishtap.com/help/array2js" ,vreferrer = "Unknown" ,vtime = "1534483949" ,vlang = "" ,vagent = "CCBot/2.0 (https://commoncrawl.org/faq/)" ,vbot = "" ,vversion = "biscuits-12y" ,vguest = "" ,vip = "54.161.49.216"
538 engine.php getContent help