break line in alert with php

Shneor :
<?php
function alert($msg) 
{
echo "<script type='text/javascript'>alert('$msg');</script>";
}
if(array_key_exists('btnRegisterAdmins', $_POST)) 
{ 
$fname = $_POST['FirstName'];
$lname=$_POST['LastName'];


if(empty($fname))
{
    $alertscript = "you need...<br />";
}
if(empty($lname))
{
    $alertscript = $alertscript  . "<br /> to be good...";
    alert($alertscript);
}
?>

The output was without a line drop and the tag itself appears. Which way can i solve this?

Jpv :

<br /> is html. Try \n instead of the <br /> tag.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=342321&siteId=1