How to concatenate single quotes in echo? (In php)

2

This problem occurred to me, I tried with some examples that I had but it does not work, it's something simple, but in php manuals, and examples that I had I could not get it to work, I need to use the single quotes inside an echo:

<php 

echo     '<div class="snipcart-details ">
	  <form action="https://link.com" method="post">
			  <button class="button w3l-cart" href="javascript:void(0);" onclick="javascript:window.open('https://link.com', '_blank');">Ver</button>
	</form>
</div>';
    
asked by MatiPHP 29.06.2018 в 23:31
source

2 answers

1

You have to escape the quotes with backslash \ like this:

<php 
echo '<div class="snipcart-details ">
    <form action="https://link.com" method="post">
        <button class="button w3l-cart" href="javascript:void(0);" onclick="javascript:window.open(\'https://link.com\', \'_blank\');">Ver</button>
    </form>
</div>';
    
answered by 29.06.2018 / 23:34
source
0

The question is not well formulated because we really do not know what you want to do.

if you want to concatenate a text in quotation marks in an echo:

 <?php
echo 'Este texto '.'y este también irán unidos';

//También puedes colocar comillas con el o sin el texto

echo '"Este texto unido'.' '.'con este saldrá entre comillas"';

//si la quieres simple, solo invierte las comillas, aunque en lo general las comillas,

echo "'este es un texto con comillas simples "."unido a otro'";

?> 
    
answered by 29.06.2018 в 23:55