显示一个包含引号的php变量 [英] display a php variable that contain quotes

查看:74
本文介绍了显示一个包含引号的php变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个xml文件,尝试将其显示为php形式。

I have an xml file for which I try do display some informations into a php form.

所以我一直在尝试执行以下操作:



So i've been trying to do something like that:

<?php 

$url="tmp/".$_GET['n_doss']."-".date('d-m-Y')."-legale.xml";
if(file_exists($url))
{

     $chaineXML= $url;
     $dom = new DomDocument();
     $dom->load($chaineXML);
     $date = $dom->getElementsByTagName('time');
     $time = DateTime::createFromFormat("d/m/Y H:i:s", $date->item(0)->nodeValue);
     $datecreditsafe=date_format($time, 'd-m-Y');
     if($dom->getElementsByTagName('errors')->length != 0)
     {
        header('Location: index.php?p=add_debiteur&n_doss='.$_GET['n_doss'].'&type='.$_GET['type'].'&mode='.$_GET['mode'].'&step=4&creditsafe=false&siret='.$_GET['siret'] );
     }
       else
      {
         if(!empty($data['forme_juridique']))
         {
              echo "<label>Forme juridique:</label><input type='text' name='forme_juridique'><br>";
         }
         else
         {
             if($dom->getElementsByTagName('legalform')->length != 0)
                 {
                 $etat = $dom->getElementsByTagName('legalform');
                 $forme_juridique=$etat->item(0)->nodeValue;    
                 echo "<label>Forme juridique:</label><input type='text' name='forme_juridique' value='".utf8_decode(stripslashes($forme_juridique))."'><br>";
                 }
                 else
                 {
                 echo'<label for="forme_juridique">Forme Juridique:</label><table width="45%"       border="0">
                        <tr>
                        <td width="50%"><input type="checkbox" name="forme_juridique" value="SAS" onclick="limite_check(this.name, 1)" />
                        SAS</td>
                        <td width="50%"><input type="checkbox" name="forme_juridique" value="SA" onclick="limite_check(this.name, 1)" />
                          SA</td>
                          </tr>
                          <tr>
                        <td><input type="checkbox" name="forme_juridique" value="SARL" onclick="limite_check(this.name, 1)" /> 
                        SARL</td>
                    <td><input type="checkbox" name="forme_juridique" value="EURL" onclick="limite_check(this.name, 1)" />
                      EURL</td>
                      </tr>
                      <tr>
                        <td><input type="checkbox" name="forme_juridique" value="SNC" onclick="limite_check(this.name, 1)" />
                    SNC</td>
                    <td><input type="checkbox" name="forme_juridique" value="SDF" onclick="limite_check(this.name, 1)" />
                  SDF</td>
                  </tr>
                  <tr>
                <td><input type="checkbox" name="forme_juridique" value="Soci&eacute;t&eacute;  Particuli&egrave;re" onclick="limite_check(this.name, 1)" />
                  Soci&eacute;t&eacute; Particuli&egrave;re </td>
                <td><input type="checkbox" name="forme_juridique" value="Entreprise Individuelle" onclick="limite_check(this.name, 1)" />
                  Entreprise Individuelle</td>
                  </tr>
                  <tr>
                <td><input type="checkbox" name="forme_juridique" value="Artisan" onclick="limite_check(this.name, 1)" />
                  Artisan</td>
                <td><input type="checkbox" name="forme_juridique" value="Commer&ccedil;ant"     onclick="limite_check(this.name, 1)" />
              Comme&ccedil;ant</td>
              </tr>
              <tr>
            <td><input type="checkbox" id="box" name="forme_juridique" value="Autre" onclick="GereControle(\'box\', \'forme_juridique2\', \'1\');limite_check(this.name, 1)"/>
              Autre</td>
            <td><input type="text" name="forme_juridique2" id="forme_juridique2" style="visibility:hidden" /></td>
              </tr>
        </table>';
                 }

            }
      }

真正的麻烦是它只向我显示此变量的一部分:实际上要显示的实际部分是:SAàconseil d'administration

But the real trouble is that it display to me only a part of this var: actually the real part to be display is: SA à conseil d'administration

并向我显示只有SAàconseil d

and it display to me only SA à conseil d

我已经尝试过几种方法:

I've tried several things like:

str_replace("'","&#039;",$str) 

htmlentities($str, ENT_QUOTES, "UTF-8")

或再次 mysql_real_escape_string

加斜杠带斜杠

但我没有找到制作方法

在此先感谢您的帮助

推荐答案

尝试用以下命令替换 echo 行:

Try replacing the echo line with this one:

echo '<label>Forme juridique:</label><input type="text" name="forme_juridique" value="' . htmlspecialchars($data['forme_juridique']).'"><br>';

这篇关于显示一个包含引号的php变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆