为什么CodeIgniter不在我的<form> </form>输入标签中设置\ n \ r?

时间:2014-08-05 11:21:36

标签: html codeigniter

根据CodeIgniter生成的HTML源代码, 为什么,对于某些标签,有\ n \ r和大多数标签之间的&lt;形式&gt;&lt; / form&gt;没有\ n \ r? (例如&lt; a&gt;和&lt; / a&gt;标记)

我该怎么做/管理\ n \ r?

 <!DOCTYPE html>
<html lang="fr">

<head>

    <meta charset="utf-8">

    <title>Chauffeurs</title>

    <link rel="stylesheet" href="http://localhost/CI/CI220_FMT1/ressources/css/styles.css" type="text/css" />

</head>

<body>

<form action="http://localhost/CI/CI220_FMT1/index.php/CHAUFFEURS/chauffeurs_c" id="englobe_tout" method="post" accept-charset="utf-8">
<div id="div_menu_general" class="flexbox">

    <a href="http://localhost/CI/CI220_FMT1/index.php/ACCUEIL/accueil" class="bouton">Accueil</a><a href="http://localhost/CI/CI220_FMT1/index.php/BIENVENUE/bienvenue" class="bouton">Bienvenue</a><a href="http://localhost/CI/CI220_FMT1/index.php/QUI_ES_TU/qui_es_tu" class="bouton">Qui es tu ?</a><a href="http://localhost/CI/CI220_FMT1/index.php/TEST2b/test2b" class="bouton">Test2b</a><a href="http://localhost/CI/CI220_FMT1/index.php/TEST2b_mvc/test2b_c" class="bouton">Test2b_c</a><a href="http://localhost/CI/CI220_FMT1/index.php/CHAUFFEURS/chauffeurs_c" class="bouton_selectionne">Chauffeurs</a><a href="http://localhost/CI/CI220_FMT1/index.php/CONTACTS/contacts_c" class="bouton">Contacts</a>
</div>
etc.

这是为&lt;上面生成HTML代码的代码片段。 div id =“div_menu_general”class =“flexbox”&gt;并且&lt; a&gt;&lt; / a&gt;标签(女巫没有任何\ n \ r):

<div id="div_menu_general" class="flexbox">

    <?PHP

    if (preg_match("/accueil/i", current_url()))
            echo anchor('ACCUEIL/accueil', 'Accueil', array('class' => 'bouton_selectionne'));

    else    echo anchor('ACCUEIL/accueil', 'Accueil', array('class' => 'bouton'));



    if (preg_match("/bienvenue/i", current_url()))
            echo anchor('BIENVENUE/bienvenue', 'Bienvenue', array('class' => 'bouton_selectionne'));
    else    echo anchor('BIENVENUE/bienvenue', 'Bienvenue', array('class' => 'bouton'));



    if (preg_match("/qui_es_tu/i", current_url()))
            echo anchor('QUI_ES_TU/qui_es_tu', 'Qui es tu ?', array('class' => 'bouton_selectionne'));
    else    echo anchor('QUI_ES_TU/qui_es_tu', 'Qui es tu ?', array('class' => 'bouton'));



    if (preg_match("/test2b/i", current_url()))
            echo anchor('TEST2b/test2b', 'Test2b', array('class' => 'bouton_selectionne'));
    else    echo anchor('TEST2b/test2b', 'Test2b', array('class' => 'bouton'));



    if (preg_match("/test2b_c/i", current_url()))
            echo anchor('TEST2b_mvc/test2b_c', 'Test2b_c', array('class' => 'bouton_selectionne'));
    else    echo anchor('TEST2b_mvc/test2b_c', 'Test2b_c', array('class' => 'bouton'));



    if (preg_match("/chauffeurs/i", current_url()))
            echo anchor('CHAUFFEURS/chauffeurs_c', 'Chauffeurs', array('class' => 'bouton_selectionne'));
    else    echo anchor('CHAUFFEURS/chauffeurs_c', 'Chauffeurs', array('class' => 'bouton'));



    if (preg_match("/contacts/i", current_url()))
            echo anchor('CONTACTS/contacts_c', 'Contacts', array('class' => 'bouton_selectionne'));
    else    echo anchor('CONTACTS/contacts_c', 'Contacts', array('class' => 'bouton'));


    ?>

</div>

1 个答案:

答案 0 :(得分:0)

如果您想格式化源代码,您必须回复&#34; \ n&#34;插入换行符,或使用CI推荐的格式,在这里你可以将PHP代码插入到html源代码中:

<div>
    <?= anchor('ACCUEIL/accueil', 'Accueil', array('class' => preg_match("/accueil/i", current_url()) ? "bouton_selectionne" : "bouton")) ?>

</div>

我也缩写你的if ... else。