1

我在 php 中使用元数据阅读器。它工作得很好,但是当我使用它将来自函数的值放入 INPUT 时,我在输入框中得到奇怪的符号。

这是源代码:

if($fileStatus == 1){
    include ("include/functions.php");
    $filename=$uploaded;
    $mp3file=new CMP3File;
    $mp3file->getid3($filename);
    $hej = "hejhejhej";
    ?>
    <form>
        <input type="text" name="hej" value="<?php echo $hej;?>">
        <input type="text" name="title" value="<?php echo "$mp3file->title";?>"><br>
        <input type="text" name="artist" value="<?php echo "$mp3file->artist";?>"><br>
        <input type="text" name="album" value="<?php echo "$mp3file->album";?>"><br>
        <input type="text" name="year" value="<?php echo "$mp3file->year";?>"><br>
        <textarea name="artist"><?php echo "$mp3file->comment";?></textarea><br>
        <input type="text" name="genre" value="<?php echo "Ord($mp3file->genre)";?>"><br>
    </form>
    <?php   
}

我从浏览器获得的源代码:

<form>
                    <input type="text" name="hej" value="hejhejhej">
                    <input type="text" name="title" value="Selene

截屏

4

3 回答 3

0

这个问题的解决方案是“Trim()”

于 2012-12-21T00:28:08.733 回答
0

您看到的奇怪字符是因为 CMP3File 使用 fread 从实际 MP3 文件中获取字节(如果您想了解更多信息,请阅读 ID3 标签)。如果您想将实际字节视为字符串,请使用 ord 函数,如下所示:

<?php
    for($i = 0; $i < strlen($mp3file->title); $i++) {  
        echo ord($mp3file->title[$i]);  
    }  
?>
于 2012-12-20T23:52:42.597 回答
0

尝试使用 HTML 实体。

这可能是因为 UTF-8 并且浏览器不支持该编码。可能是,PHPhtmlentities可能会帮助你。代替:

<?php echo $hej;?>

和:

<?php echo htmlentities($hej);?>
于 2012-12-20T23:49:41.303 回答