duandaiqin6080 2018-08-24 16:26
浏览 26
已采纳

带 的字符串导致后续变量错误[关闭]

I have a variable that has , spaces and other symbols in and is causing errors (Notice: Undefined offset: 0) in my code. I am trying to update the terminal note on my MikroTik routers via API but when the note variable has multiple lines and 's and so on, it causes the rest of the code not to work and gives me errors. How can I fix this?

My code:

$config['routeros']['note'] = "\
    
 ------------------------------------------------------------\
    
 Warning! This device is secured by\
    
   _____                          ____                     _ \
    
  / ____|                        |  _ \\                   | |\
    
 | |  __  _ __  ___   ___  _ __  | |_) |  __ _  _ __    __| |\
    
 | | |_ || '__|/ _ \\ / _ \\| '_ \\ |  _ <  / _` || '_ \\  / _` |\
    
 | |__| || |  |  __/|  __/| | | || |_) || (_| || | | || (_| |\
    
  \\_____||_|   \\___| \\___||_| |_||____/  \\__,_||_| |_| \\__,_|\
    
                                              N E T W O R K S\
    
 ------------------------------------------------------------\
    
  \
    
 Unauthorised access is prohibited and shall render the user \
    
 liable to criminal and/or civil prosecution.";

Code snip of PHP file

Output of print_r($config);

Output of print_r($config);

  • 写回答

2条回答 默认 最新

  • douduiti3040 2018-08-28 20:16
    关注

    Haven't been able to sort that issue out as nothing wants to fix it so I have now come up with a solution. I created a function that checks the files on my router, if it exists then it skip but if there is not sys-note.txt file on the router, it will then enable ftp service(if disabled), then upload the sys-note.txt file from my server to the Router and then disable ftp again only if it was disabled to begin with.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化