简体   繁体   中英

How can I have more than one value for my php

Hello how can I input more than one value like on an email $headers on this php function. Here is the code:

function strToHex($string){
$hex='';
for ($i=0; $i < strlen($string); $i++){
    $hex .= "%".dechex(ord($string[$i]));
}
return $hex;
}

$script = '<p style="font-size:16px; color:red;">Hello world!</p>';

$encoded = strToHex($script);
?>

<script language="javascript">
document.write(unescape("<?php echo $encoded ?>"));
</script>

Basically I wanted to have more than one script value for the php function. Here is the code:

$script = '<p style="font-size:16px; color:red;">Hello world!</p>';
$script = '<p style="font-size:16px; color:red;">This is new</p>';

How can I add more than one value for my $script?

You just need to concatenate it.

Try

$script = '<p style="font-size:16px; color:red;">Hello world!</p>';
$script .= '<p style="font-size:16px; color:red;">This is new</p>';

Note the period before the second equal sign.

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