This looks like JavaScript being generated by JavaScript. So the thing is a bit different than it asks. To make PHP write this, you will have to choose which type of delimiter to use in PHP and then define the delimiter that will be escaped.
Example, retaining the original form:
<options += '<option value="' + j[i].CodCidade + '">' + j[i].NomeCidade + '</option>';
To put this inside a PHP variable would look like this:
$foo = "<options += '<option value=\"' + j[i].CodCidade + '\">' + j[i].NomeCidade + '</option>';";
Here we use the double quote as a delimiter, so all double quotes of the string must be escaped with backslash
Another way, using hered
$foo = <<<HTML
<options += '<option value="' + j[i].CodCidade + '">' + j[i].NomeCidade + '</option>';
HTML;
The advantage is that you do not have to escape anything except in very specific cases. So just throw everything in the original form.
Be careful with closing. In the above example, HTML;
can not contain spaces or tabs at the beginning.
This is much cleaner and handy for dealing with templates since it does not need to leak. It is very convenient to assign extensive codes where it would take a lot of work to do all the leaks.
Let's complicate this with an example of output buffering
>
<?php
ob_start();
?>
<options += '<option value="' + j[i].CodCidade + '">' + j[i].NomeCidade + '</option>';
<?
echo ob_get_clean();
Output control is used for specific cases. Obviously not used for simple and common cases where we can solve with concatenation or heredoc. An example of using output buffering is compiling templates.
* terms used:
double quote -> aspa dupla
backslash -> barra invertida