Welcome Guest, Not a member yet? Register   Sign In
PHP/CI ruining tabbing and ignoring new lines in document
#1

[eluser]gh0st[/eluser]
I'm having an issue with CI ruining the tabbing in my PHP documents and ignoring new lines, despite me putting them in the PHP document.

The document is saved as UTF-8. The HTML is using the UTF-8 in the charset.

For example;

Code:
Date?<br />

&lt;?php
$thisday = date("j");
?&gt;
<select class="day" name="day">
&lt;?php
for ($i=1; $i<=31; $i++):

    if ($i == $thisday)
    {
        $sel = ' selected="selected"';
    } else {
        $sel = '';
    } // end if

    $output = ('<option value="'.$i.'"'.$sel.'>'.$i.'</option>');
    echo $output;
endfor;
?&gt;
</select>

Notice the end select is on a new line, and the output is implied to be one per line... but everything is being outputted on ONE line -- even the end select tag is appended on the end of the huge option list.

Why does PHP/CI do this and how do I fix it?

Code:
Date?<br />
                                        <select class="day" name="day">
                    <option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7" selected="selected">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option><option value="11">11</option><option value="12">12</option><option value="13">13</option><option value="14">14</option><option value="15">15</option><option value="16">16</option><option value="17">17</option><option value="18">18</option><option value="19">19</option><option value="20">20</option><option value="21">21</option><option value="22">22</option><option value="23">23</option><option value="24">24</option><option value="25">25</option><option value="26">26</option><option value="27">27</option><option value="28">28</option><option value="29">29</option><option value="30">30</option><option value="31">31</option>                    </select>
#2

[eluser]Developer13[/eluser]
$output = ('<option value="'.$i.'"'.$sel.'>'.$i.'</option>');

should be

$output = ('<option value="'.$i.'"'.$sel.'>'.$i."</option>\r\n");

Notice the double quotes and not single quotes wrapping the closing tag.
#3

[eluser]gh0st[/eluser]
Ah many thanks!




Theme © iAndrew 2016 - Forum software by © MyBB