Php
PHP: Hypertext Preprocessor (or simply PHP) is a server-side scripting language designed for web development but also used as a general-purpose programming language. It was originally created by Rasmus Lerdorf in 1994.
The PHP interpreter only executes PHP code within its delimiters. Anything outside its delimiters is not processed by PHP, although non-PHP text is still subject to control structures described in PHP code.
The most common delimiters are to close PHP sections. The shortened form <? also exists. This short delimiter makes script files less portable, since support for them can be disabled in the local PHP configuration and it is therefore discouraged.However, there is no recommendation against the use of the echo short tag <?=Prior to PHP 5.4.0, this short syntax for echo() only works with the short_open_tag configuration setting enabled, while for PHP 5.4.0 and later it is always available. The purpose of all these delimiters is to separate PHP code from non-PHP content, such as JavaScript code or HTML markup
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.