Codeigniter
CodeIgniter is a powerful PHP framework with a very small footprint, built for developers who need a simple and elegant toolkit to create full-featured web applications.
This page isn’t working Chrome detected unusual code on this page and blocked it to protect your personal information. ERR_BLOCKED_BY_XSS_AUDITOR
This page isn't working
Chrome detected unusual code on this page and blocked it to protect your personal information (for example, passwords, phone numbers, and credit cards).
ERR_BLOCKED_BY_XSS_AUDITOR

This page isn’t working – ERR_BLOCKED_BY_XSS_AUDITOR
Mainly,
This error message is occurs when we are trying to post a content with HTML tags or Scripts Tags or Like When Google Chrome believes a “cross-site scripting” attack is happening. These attacks happen when a browser is tricked into rendering HTML or JavaScript that is not meant to be a part of the website being displayed.
Then Chrome Generates This ERROR ”
ERR_BLOCKED_BY_XSS_AUDITOR “
For PHP and All Other PHP Frameworks: Add this below line before post
header('X-XSS-Protection:0');
Print the Div Contents in Php or Javascript
The JavaScript is below..
<script type="text/javascript">
var base_url="<?php echo $this->request->webroot; ?>";
function printDivContents(divID="xshr_print_section") {
//Get the HTML of div
var divElements = document.getElementById(divID).innerHTML;
Popup(divElements);
}
function Popup(data) {
var mywindow = window.open('', 'new div', 'height=400,width=600');
mywindow.document.write('<html><head><title></title>');
mywindow.document.write('<link rel="stylesheet" href="'+base_url+'"css/print.css" type="text/css" />');
mywindow.document.write('</head><body >');
mywindow.document.write(data);
mywindow.document.write('</body></html>');
mywindow.print();
return true;
}
</script>
The HTML file is like-
<div id="xshr_print_section">
<!-- here the printing Contents -->
-
-
-
</div>
PHP – Foreach Pass-by-Reference ? Do it now!
Normally, when we are using the “Pass-By-Reference” in the foreach block we write code like below..
foreach ($array as &$row) {
// we Just Do Our stuff
}
We Must Have to “Unset” when we use “Pass-by-Reference”. Otherwise the array data may be altered. So, BEWARE.!
foreach ($array as &$row) {
// We Just Do Our stuff
// Now Unset after the Stuff
unset($row);
}
Don’t forget to “unset” the reference variable after the loop.
//---------------------------------
// Normally we do
//---------------------------------
$main_array = array('1','2','3','4');
$sub_array = array('11','22','33','44');
print_r($main_array);
print_r($sub_array);
/*
# Actual Array Data:
Array
(
[0] => 1
[1] => 2
[2] => 3
[3] => 4
)
*/
$main_text = "";
foreach($main_array as &$row) {
$main_text .= $row.',';
}
$sub_text = "";
foreach($sub_array as $row) {
$sub_text .= $row.',';
}
print_r($main_array);
print_r($sub_array);
/*
# (main_array) Altered Data:
Array
(
[0] => 1
[1] => 2
[2] => 3
[3] => 44
)
# (main_array) Expected Data:
Array
(
[0] => 1
[1] => 2
[2] => 3
[3] => 4
)
*/
//-------------------------------
// We Have to Use Like this
//-------------------------------
$main_text = "";
foreach($main_array as &$row) {
$main_text .= $row.',';
//Unset the pass-by-reference variable
unset($row);
}
/*
// Now the Result will not altered
Array
(
[0] => 1
[1] => 2
[2] => 3
[3] => 4
)
*/
This is because when the second loop executes, $row is still a pass-by-reference variable.
Thus, with each iteration the original reference is overwritten.