php - 语法错误 : '' string literal contains an unescaped line break

标签 php html module syntax-error

我有一个控制台错误告诉我这个:

SyntaxError: '' string literal contains an unescaped line break



我已多次检查语法,但无法更正错误。如果您能识别出某些内容,我会将代码复制给您。
    $('#nouveau').click(function(){
        $('#action').html('<?php echo preg_replace('/\s\s+/', '', $langs->trans("Delete") ); ?>');
        $('.titre_ecv').html('<?php echo addslashes(trim(preg_replace('/\s\s+/', '', $langs->trans("ecv_nouveau_formation")))); ?>');
        $('.nouveau').show();
        $('#valider').show();
        $id=$('#tr_formations tr').length+1; 
        $('#tr_formations').append('<tr><td><input name="action" type="hidden" value="create"><input type="text" name="formations['+$id+'][etablissement]" autocomplete="off" style="width:95%" /></td> <td style="width:10%;"> <select class="niveau flat" id="niveau" name="formations['+$id+'][niveau]" ><option value="0" ></option><option value="Qualifiant"  ><?php echo preg_replace('/\s\s+/', '', $langs->trans("Qualifiant") ); ?></option><option value="Bac" >Bac </option> <option value="Bac+1" >Bac+1 </option><option value="Bac+2" >Bac+2 </option><option value="Bac+3" >Bac+3 </option><option value="Bac+4" >Bac+4 </option><option value="Bac+5" >Bac+5 </option><option value="Master_specialisé" ><?php echo preg_replace('/\s\s+/', '', $langs->trans("Master_specialisé") ); ?> </option><option value="Master_recherche" ><?php echo preg_replace('/\s\s+/', '', $langs->trans("Master_recherche") ); ?> </option> <option value="Doctorat" >Doctorat </option></select> </td> <td ><input type="text"  name="formations['+$id+'][intitule]" autocomplete="off" style="width:95%" /></td> <td><input type="text"  name="formations['+$id+'][filiere]" autocomplete="off" style="width:95%" /></td><td style="width:8%;"><input type="text" name="formations['+$id+'][debut]" class="datepicker debut" value="<?php echo date('d/m/Y') ?>" onchange="MinDate(this);" autocomplete="off" /></td> <td style="width:8%;"><input type="text" name="formations['+$id+'][fin]" value="<?php echo date('d/m/Y') ?>" class="datepicker fin" onchange="MaxDate(this);" autocomplete="off" /><div align="center"><label><input type="checkbox" name="experiences['+$id+'][no_jours]" onchange="no_jourss(this);"> <b class="nos_jour"><?php echo trim(preg_replace('/\s\s+/', '', $langs->trans("ecv_no_jours") )); ?></b></label></div> </td><td align="center"><img src="<?php echo DOL_MAIN_URL_ROOT.'/theme/md/img/delete.png' ?>" class="img_delete" onclick="delete_tr(this);"></td></tr>');
        $( ".datepicker" ).datepicker({
            dateFormat: 'dd/mm/yy'
        });
        $(".niveau").select2()
    });

我的工作是纠正现有代码。感谢您的帮助

最佳答案

 $('#action').html(...)


 $('.titre_ecv').html(...)

混合了 ' 和 ",所以应该有错误。
虽然那 <?php...不应该工作,因为 PHP 在服务器上运行,而不是在 Web 浏览器上。

编辑

这可能有效:
$('#action').html("<?php echo preg_replace('/\s\s+/', '', $langs->trans('Delete') ); ?>");
$('.titre_ecv').html("<?php echo addslashes(trim(preg_replace('/\s\s+/', '', $langs->trans('ecv_nouveau_formation')))); ?>");

关于php - 语法错误 : '' string literal contains an unescaped line break,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59625312/

相关文章:

PHP:警告:count():参数必须是数组或实现 Countable 的对象

php - 使用 array_filter 和 array_splice 从行加载特定字段,之后想要清空字段

java - 如何将数据库中的信息(使用 java 代码检索)打印为 html?

ruby-on-rails - ruby /rails : How to determine if module is included?

python - 跨模块变量

PHP 在远程服务器上读取/写入文件

html - 没有js的固定纵横比和固定高度的元素

android - Jsoup在不重复的情况下获取具有相同类名的内部div中的文本

javascript - 离开文本区域时按钮单击不触发

ruby - 是否可以为 Ruby 中的模块创建别名?