How to use single quotes when I have php text [duplicated]

0

Hello, it is possible for example when I write the following code:

$content=' //incluir texto con comillas simples l'informatique por ejemplo ';

Is it that I use single quotes and sometimes I add text from php and obviously it cuts me is there any way? My question is quite simple so I do not think I have to give more details.

    
asked by Perl 16.09.2016 в 11:49
source

3 answers

4

Well, I can give you options:

//OPCION 1
 $content="//incluir texto con comillas simples l'informatique por ejemplo ";


//OPCION 2
 $content2='//incluir texto con comillas simples l\'informatique por ejemplo ';

Greetings.

    
answered by 16.09.2016 в 12:16
1

The problem is in the sample that you have only 3 single quotes in a text that you are dividing.

Replace:

  $content = ' //incluir texto con comillas simples l'informatique por ejemplo ';

By:

  $content = ' //incluir texto con comillas simples l' 'informatique por ejemplo ' ';

Example:

  $x=' Aqui puede haber " dentro de la cadena';
  $x=" Aqui puede haber ' dentro de la cadena";

In the first case the single quote 'opens and closes the chain so it is possible to put a double quote in it.

The second case is the inverse, you put a single quote 'inside the open block and closed by double quotes "

  

Documentation: When do you use single and double quotes in PHP?

answered by 16.09.2016 в 12:28
0

Use double quotes. So you can use the simple ones without any problem. In such ways, it is advisable to use double for when you start to put variables.

$content=" //incluir texto con comillas simples l'informatique por ejemplo ";
    
answered by 11.09.2017 в 13:27