preg_replace 在命令行中有效,但在浏览器中无效?
我有一个 sql 文件,里面有注释。
/*
IMP : Only use C-Style comments only
Every ID field should have this convention "tableName_id" ,
where tableName is the name of table, whom this id refers
*/
/*
It stores the system wide information
we need at the time of updates or debugging.
*/
CREATE TABLE IF NOT EXISTS `#__payplans_support` (
`support_id` INT NOT NULL AUTO_INCREMENT,
`key` VARCHAR(45) NOT NULL ,
`value` TEXT NULL,
PRIMARY KEY (`support_id`) ,
UNIQUE INDEX `idx_key` (`key` ASC)
)
ENGINE = MyISAM
DEFAULT CHARACTER SET = utf8 ;
CREATE TABLE IF NOT EXISTS `#__payplans_config` (
`config_id` INT NOT NULL AUTO_INCREMENT,
/*name of tab*/
`title` VARCHAR(255) NOT NULL,
`key` VARCHAR(255) NOT NULL,
`config` TEXT NULL ,
`componentname` VARCHAR(255) NULL,
/* xml and default ini path */
`path` TEXT NULL,
PRIMARY KEY (`config_id`) ,
INDEX `idx_key` (`key` ASC)
)
ENGINE = MyISAM
DEFAULT CHARACTER SET = utf8 ;
下面的代码过滤了上面sql中的注释。
$sql = file_get_content(from above file);
$var = preg_replace("!/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/!s","",$sql); // EDIT
问题:
它在 Linux 中完美运行(命令行和浏览器)。
但它不能从浏览器在 Windows 上工作,但使用 Windows 命令行时,浏览器显示 连接已重置...
请给我任何解决方案。
I have a sql file which has the comments inside it.
/*
IMP : Only use C-Style comments only
Every ID field should have this convention "tableName_id" ,
where tableName is the name of table, whom this id refers
*/
/*
It stores the system wide information
we need at the time of updates or debugging.
*/
CREATE TABLE IF NOT EXISTS `#__payplans_support` (
`support_id` INT NOT NULL AUTO_INCREMENT,
`key` VARCHAR(45) NOT NULL ,
`value` TEXT NULL,
PRIMARY KEY (`support_id`) ,
UNIQUE INDEX `idx_key` (`key` ASC)
)
ENGINE = MyISAM
DEFAULT CHARACTER SET = utf8 ;
CREATE TABLE IF NOT EXISTS `#__payplans_config` (
`config_id` INT NOT NULL AUTO_INCREMENT,
/*name of tab*/
`title` VARCHAR(255) NOT NULL,
`key` VARCHAR(255) NOT NULL,
`config` TEXT NULL ,
`componentname` VARCHAR(255) NULL,
/* xml and default ini path */
`path` TEXT NULL,
PRIMARY KEY (`config_id`) ,
INDEX `idx_key` (`key` ASC)
)
ENGINE = MyISAM
DEFAULT CHARACTER SET = utf8 ;
The code below filters the comment from above sql.
$sql = file_get_content(from above file);
$var = preg_replace("!/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/!s","",$sql); // EDIT
PROBLEM :
It is working perfectly in Linux (Command Line and from browser).
But It in not working on windows from Browser, but working with Windows command line the browser shows The connection was reset...
Please give me any solution.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在这里没有得到任何正确的解决方案。所以我只是从sql文件中删除了注释。
I didn't get any correct solution here. So I just removed the comments from sql file.