PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Are you sure it's not happening? Have you checked the HTML source? Bear in mind that line breaks are ignored by HTML, so you wouldn't see it displayed on the page.
<?php
$variable = "name";
$literally = 'My $variable will not print!\\n';
print($literally);
$literally = "My $variable will print!\\n";
print($literally);
?>
No line breaks occur - this is the output:-
"My $variable will not print!\nMy name will print!\n"
Well, as I mentioned already, line breaks are ignored by HTML so you wouldn't see them in your browser output, only in the source. Secondly, you're escaping the backslash, meaning that's not a line break character anyway. If you want line breaks in your HTML, use <br>
PHP is not limited to sending output to the browser. While HTML may disregard line breaks, they're useful in creating mail headers, say, or writing to files.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.