简体   繁体   中英

Printing php variables

Hello Everyone I am doing some coding in php i want to print php variable with error message i tried so many methods but its not working,. CAn anubody give suggestion how to solve this Here is my code

$job_validate_demux_type = $this->validate_possible_value($gstaf_format_demux["demux_format"],explode(",",$validate_array[38]));

        if($job_validate_demux_type == "empty")
        {
            array_push($gstaf_format_demux_array,"Demux Format is empty");
        }
        else if($job_validate_demux_type == "invalid")
        {
            array_push($gstaf_format_demux_array,"Demux Format value is invalid ");
        }

I am doing some validation i need to print the value of php variable with error message for ex: array_push($gstaf_format_demux_array,"Demux Format value is invalid "); i need to print $gstaf_format_demux["demux_format"] value with error message.Please help me to solve this

You can use echo , print_r or var_dump ;

Echo command printing only strings. (cannot convert array to string)

Print_r command printing strings and arrays (recursive).

Var_dump command printing string and arrays. (with variable type)

I think the best way for this code will be echo , because you wan't print string.

Example:

echo "Demux Format is empty\\n"

foreach ($errors as $error) { echo "$error[message]\\n"; }

\\n is new line

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM