I have a problem in display or echo in php.

what method should i follow if i the problem is with like this:
example code:

$email = trim($_REQUEST["email"]);

if(strlen($email) < 1){
echo "0__notice__Email is empty.";
}

but the output should display only this part
"Email is empty." only and not the whole echo.

"Email is empty." --> this part only
"0__notice__Email is empty." --> not the whole display like this.

you decide what the function echo should display but if this is error message stored in array of errors for example and you want to get rid of the these characters when displaying the error , then use a function

<?php

function clean_error($error) {
return str_replace("0__notice__","",$error);
}

echo clean_error("0__notice__Email is empty");

?>
commented: thanks +1

Didn't understand the logic of writing echo "0__notice__Email is empty."; and expecting Email is empty as output. Can u explain..

if(strlen($email) < 1){
    echo "0__notice__Email is empty.";
}
// the expected result is "0__notice__Email is empty."
// change your echo to this:
if(strlen($email) < 1){
    echo "Email is empty.";
}
// the expected result is "Email is empty."

http://php.net/manual/en/function.echo.php

to: vibhadevit
thanks but i try to use this "error message" for ajax, its only has simple logic. the underscore mark would be my delimiter and the "0" refer to my status. well i've already solve the problem. thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.