Search for the nl2br function or concatene: print "you can Eat: $Dish"." <br />";

Asked

Viewed 71 times

-1

   Pesquisei ,e,encontrei essa teoria bem explicadinha aqui nesse site: "https://imasters.com.br/artigo/3296/php/dica-funcao-nl2br-php-no-dreamweaver/?trace=1519021197&source=single".

But apply the theory well explained above in practice ,in this code below , is that are other 100% ,that I still do not know how to do ,if the noble friend knows ,I would appreciate ,that put the same there in LOCO, if you do not know, I am waiting ,who knows,and researching at the same time. WHERE AND HOW SHOULD I PUT " >>> nl2br<< , In this my code below:

3.00, 'Braised Bamboo Fungus'); foreach ($Dinner as $Dish) { print "You can Eat: $Dish n"; } >? _______________________________________________________________________________________________________________________________________________ To stay functional as it was put in this other one below : _______________________________________________________________________________________________________________________________________________

See in practice the above code working (this is how I want mine to work) :

Let’s go to the codes. Suppose you is rescuing this text from a database for example, then you’d have a code like this:

And this would result in this example:

Lorem ipsum dolor sit Amet, consectetuer adipiscing Elit, Minim veniam, quis nostrud exerci tation ullamcorper sus Velit that molestie consequat, vel illum dolore I feugiat duis dolore te feugait nulla facilisi Lorem ipsum dolor sit erat volutpat. Ut wisi enim ad Minim veniam, quis nostru dolor in hendrerit in vulputate Velit esse molestie conseq luptatum zzril delenit augue duis dolore te feugait nulla fa

As you realized it gets difficult and without stimulating the reading of the text. To solve we use function nl2br so:

With the function in use we will have:

Loren ipsum dolor sit Amet, consectetuer adipiscing Elit Minim veniam, quis nostrud exerci tation ullamcorper su Velit that molestie consequat, vel illum dolore I feugiat duis dolore te feugait nulla facilisi.

Lorem ipsum dolor sit Amet, consectetuer adipiscing Elit Minim veniam, quis nostrud exerci tation ullamcorper su Velit that molestie consequat, vel illum dolore I feugiat duis dolore te feugait nulla facilisi.

The tips is simple and the difference is clear and from now on your texts on the web will be more pleasant and inviting for reading.

Here is the simple question : How to put this saying whose "MILACROSO", in this my code: ?

$Dinner = array('Sweet Corn and Asparagus', 'Lemon Chicken', 'Dried Mulberries' => 3.00, 'Braised Bamboo Fungus');

foreach ($Dinner as $Dish) {

print "You can Eat: $Dish n"; }

?>

  • 1

    Code for the love of Jesus.

  • Dude, that’s the weirdest thing I’ve ever come across when I change <?php ? > to error

  • Your code does not contain syntax error. What might be causing the error is this here. The strange thing is that you are getting the error even not using constants in the code. This presumes that you are using php7.2.

  • @fajuchem I copied the code and put it to run here and presented the same problem of it, however, when I changed the <?php ? >, I simply rewrote, the problem is over

  • Inside the php tags put phpinfo(); and see what version of your php is. Comment the other lines to avoid error

1 answer

1

The problem is in a Unicode Character used within php tags depending on the IDE or editor you use it may have become "invisible". The Character is this one "<200b>".

Here is an image showing the problem.

inserir a descrição da imagem aqui

Browser other questions tagged

You are not signed in. Login or sign up in order to post.