So it appears that you have trouble to separate your strings with either " or ’ (single or double quote) when you have HTML in those strings.
In PHP, you can use both, either double-quote or single-quote to surround a string.
For example, you could do:
$text = "this is a text";
$text = 'this is a text';
Both works. The difference is that with the double-quote, you can use variable inside it and PHP will change the variables for its value. For example:
$myvar = "hello";
$text = "this is some random text: $myvar"
if you echo the variable $text, it will give you
this is some random text: hello
If you try it with single quote, like this:
$myvar = “hello”;
$text = “this is some random text: $myvar”
this is some random text: $myvar
PHP didn’t try to parse the string and change the variable $myvar because I used single quotes.
Now, you can use the double quotes or single quotes. Single quotes are faster, but you shouldn’t notice it until you treat thousands of string. So you can choose whatever you want.
For HTML, it’s the same thing for arguments. You can use double quotes or single quotes. Example:
is the same as
You can’t however, in PHP and HTML, start a string with a double-quote and close it with a single quote. It has to be the same.
So, when you mix HTML and PHP, you should choose one separator for PHP and one for HTML. IMO, using double quotes for PHP and single quote for HTML is easier to read, but it’s just personal thing.
echo "<form action='index.php'>";
When you need to add variable in this, yes, you can use the point “.” to concatenate strings with variables. However, since using double-quotes with PHP will change the variable inside it, you could write
echo "<select name='$select_name' id='$select_id'>";
echo "<select name=" . $select_name . " id=" . $select_id . ">";
See how the first piece of code is easier to read than the second?
Or, as @ralphm suggested, you can also use:
echo '<select name="' . $select_name . '" id="' . $select_id . '">';
But, IMO, it’s harder to read, but you choose whatever you want.
Also, please consider not echoing HTML and just outputting it like this:
<select name="<?= $select_name ?>" id="<?= $select_id ?>">
<?php foreach ($items as $key => $value): ?>
<option value='<?= $key ?>'><?= $value ?></option>
<?php endforeach; ?>
IMO, this is even more easier to read.
I also wrote a post about dealing with quotations with PHP if you’re interested to know more. If you read it, don’t hesitate to tell me your opinion