English 中文(简体)
PHP 打开粗略标签的 error差
原标题:PHP parse error for opening curly bracket [closed]

我在操作该法典时正在发现这种不熟悉的错误。 我看不到什么错误。

Error: Parse error: syntax error, unexpected { in /var/www/crawler/sources.php on line 2

<?php
sourcelist($filename =  /var/resources/sources.list ){

if (is_readable($filename)){
$handle = fopen($filename, "r");
$contents = fread($handle, filesize($filename));
fclose($handle);

return(json_decode($contents));

} else {
return NULL;
}

}



print_r(sourcesList());
?>

这正是我所操作的 code。 什么错误?

最佳回答

您重新尝试确定一项职能,但您错失了<条码>功能<>。 关键词:

sourcelist($filename =  /var/resources/sources.list ){

应当

function sourcelist($filename =  /var/resources/sources.list ){

见关于购买力平价功能的文件。

问题回答

3. 请更正如下:

function sourcelist($filename =  /var/resources/sources.list ){

你们的期望

sourcelist($filename =  /var/resources/sources.list ){

}

to do? Never heard of that construct

假设你试图define <>/strong> a sourcelist 在此功能中(有一条具有违约价值的论据)。 页: 1 因此,你的代码从<>->->-->->->-->>>------>>>-----------------------------------------------------------------------------------------------------------------------------------------------------------------

第二行应改为:

function sourcelist($filename =  /var/resources/sources.list ){

引言

<?php
$filename = "/var/resources/sources.list"

function sourcelist($filename){

     if (is_readable($filename)){
     $handle = fopen($filename, "r");
     $contents = fread($handle, filesize($filename));
     fclose($handle);
     return(json_decode($contents));
     } else {
     return NULL;
     }

}

print_r(sourcesList($filename));
?>




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...