Search code examples
phpcodeigniternewlineline-breaks

Why automatic newline not working on CodeIgniter?


I checked all the files searching extra spaces before and after <?php or ?> tags without results. Someone knows why Codeigniter is outputing HTML code without the newline?

For example:

<?php
    echo form_open('/login/validate_credentials');
    echo form_input('email', '', 'id="email" placeholder="Email"');
    echo form_password('password', '', 'id="password" placeholder="password"');
    echo form_submit('submit', 'login');
    echo anchor('/login/signup', 'sign up');
    echo form_close();
?>

I expect:

<form action="http://localhost/login/validate_credentials" method="post" accept-charset="utf-8">
<input type="text" name="email" value="" id="email" placeholder="Email" />
<input type="password" name="password" value="" id="password" placeholder="password" />
<input type="submit" name="submit" value="login"  />
<a href="http://localhost/login/signup">sign up</a>
</form>

But i get:

<form action="http://localhost/login/validate_credentials" method="post" accept-charset="utf-8"><input type="text" name="email" value="" id="email" placeholder="Email" /><input type="password" name="password" value="" id="password" placeholder="Contraseña" /><input type="submit" name="submit" value="Iniciar Sesion"  /><a href="http://localhost/login/registro">Crear Cuenta</a></form>

This is not only happening with form helper, for example i am using Facebook Connect and when i do var_dump($fb_data) i get:

array(2) { ["me"]=> array(11) { ["id"]=> string(17) "101654498872" ["email"]=> string(20) "example@gmail.com" ["first_name"]=> string(8) "My Name" ["gender"]=> string(4) "male" ["last_name"]=> string(6)...... bla bla bla more code

Any help? Thanks.


Solution

  • You are not adding newlines... Try the following:

    <?php echo form_open('/login/validate_credentials'); ?>
    <?php echo form_input('email', '', 'id="email" placeholder="Email"'); ?>
    <?php echo form_password('password', '', 'id="password" placeholder="password"'); ?>
    <?php echo form_submit('submit', 'login'); ?>
    <?php echo anchor('/login/signup', 'sign up'); ?>
    <?php echo form_close(); ?>
    

    For the var_dump(), use the following method to echo it:

    <?php echo print_r(var_dump($variable),true); ?>
    

    And in a browser, use the following for 'pretty print':

    <pre><?php echo print_r(var_dump($variable),true); ?></pre>