Black Dev's Team Forum

You are not logged in.

Announcement

You have a problem about programation ? Post it on the forum !
Black devs Team Security System Coming soon.
  • Index
  •  » PHP
  •  » [FR/EN]: La méthode EOF ou les chaînes de caractères sans soucis !

#1 04-01-2010 19:04:44

Xeiyanide
Member
Registered: 22-08-2009
Posts: 2

[FR/EN]: La méthode EOF ou les chaînes de caractères sans soucis !

Vous en avez marre de ces putain d'apostrophes et autres double-quote qui pourrissent toutes vos chaînes de caractères. Les anti-slash, vous n'en pouvez plus ? La concaténation de variables rend votre code dépravé ?

La solution est simple : la méthode EOF (End Of File).

En fait, à vrai dire, cette méthode ne s'appelle pas la méthode EOF et n'a pas de nom précis. La méthode consiste à ouvrir une variable et pouvoir y mettre tout le texte désiré, espacé comme il se doit (utile pour du HTML en variable).

Son utilisation ? Très simple.
Commençons :

Code:

<?php

$mavariable = <<<EOF
Mon texte bien espacé et qui finit
par très bien se placer. Oh mon
dieu quand je repense aux longues
heures où je devais recourir à ces
antislash ! Maintenant, me voilà liiibre
''''''''''' """"""""""""""" '''''''''''' """"""""""
Mouhahahahhahahah
EOF;

?>

Du début à la fin de la zone EOF, notre texte est stocké dans la variable. La tradition veut que nous utilisions EOF au début et à la fin de notre grande chaîne de caractères mais vous pourrez remplacer ces trois lettres par celles de votre choix, tant que ce sont les mêmes en début et à la fin.

Code:

<?php

$mavariable = <<<ANTISLASHSDEMERDE
Mon texte bien espacé et qui finit
par très bien se placer. Oh mon
dieu quand je repense aux longues
heures où je devais recourir à ces
antislash ! Maintenant, me voilà liiibre
''''''''''' """"""""""""""" '''''''''''' """"""""""
Mouhahahahhahahah
ANTISLASHSDEMERDE;

?>

Eh bah voilà, c'était pas la peine de s'énerver smile
Merci à tous et à toutes smile


-------------------------------------------------------------------------


You don't want to use any trick to bypass your quotation and double-quotation marks ? You don't care about the backslashes ? The variables concatenation, you don't want to use that ?

Today, you got a solution : the EOF (End Of File) method.

In reality, this method doesn't got a name. With taht method, you can store text into variables without the problems of the slashes and the quotation marks.

How to use ? Very easy.
Let's begin :

Code:

<?php

$myvariable = <<<EOF
My very-well-spaced text
can be stocked esaily. Oh my
god, when I think about these long
hours using backslashes ! 
Now, all that's finish. I'm freeeeee !
''''''''''' """"""""""""""" '''''''''''' """"""""""
Mouhahahahhahahah
EOF;

?>

Beetwin the begin and the end of the text, we got EOF marks. The tradition is to use EOF at the begin and at the end of your text but you can replace these three letters by your choice, but you need to use the same at the beginning and the end of the text.

Code:

<?php

$myvariable = <<<FUCKYOUBACKSLASHES
My very-well-spaced text
can be stocked esaily. Oh my
god, when I think about these long
hours using backslashes ! 
Now, all that's finish. I'm freeeeee !
''''''''''' """"""""""""""" '''''''''''' """"""""""
Mouhahahahhahahah
FUCKYOUBACKSLASHES;

?>

All is done. Well, you didn't need to be so angry !
Thanks for reading this tutorial.

Offline

 

#2 04-01-2010 22:46:45

Zer01ne
Site Admin
Registered: 22-08-2009
Posts: 44
Website

Re: [FR/EN]: La méthode EOF ou les chaînes de caractères sans soucis !

Very nice tuto

Offline

 
  • Index
  •  » PHP
  •  » [FR/EN]: La méthode EOF ou les chaînes de caractères sans soucis !

Board footer

Propulsé par FluxBB
Traduction par FluxBB.fr