dpzp5127 2012-05-02 23:33
浏览 54

在为站点创建配置系统时遇到(警告:非法字符串偏移)

I like this kind of configuration because it's more cleaner therefore I have a configuration file with the following:

<?php
 $Config['option_1'] = 'some value';
 $Config['option_2'] = 'some value';
 $Config['option_3'] = 'some value';
?>

Then i have a class with a method to load this kind of configuration files It's very similar with how CodeIgniter loads the configuration files except when i include this file I get:

Warning: Illegal string offset 'option_1' in 'Path to the config file' on line #.
Warning: Illegal string offset 'option_2' in 'Path to the config file' on line #.
Warning: Illegal string offset 'option_3' in 'Path to the config file' on line #.

etc. You get the idea.

I've searched everywhere on how to use this kind of configuration system on a site but no result. So if anyone has a link to a tutorial or some documentation on this then please help me understand how this works or why i get that error when I require the configuration file from inside a class using one of it's methods.

Note. When i load the configuration file directly into the browser I get no errors and I can successfully echo out any values using "echo $Config['option_1'];"

  • 写回答

1条回答 默认 最新

  • duan0514324 2012-05-02 23:35
    关注

    if you do

    var_dump($Config);
    

    you'll see that it's not an array like you think.

    评论

报告相同问题?

悬赏问题

  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程