English 中文(简体)
为什么要把“姓名不能空洞”的错误归来?
原标题:Why does file_get_contents() return the error "Filename cannot be empty"?
  • 时间:2009-12-10 16:09:01
  •  标签:
  • php

I m 相对而言,是PHP的一个完整的新项目。 我的背景是C/C++和C#.Im试图反对将一些简单的PHP代码定位为导向,但Im却做了一些错误的事情。

班级代码:

class ConnectionString
{
  public $String = "";
  public $HostName = "";
  public $UserName = "";
  public $Password = "";
  public $Database = "";

  function LoadFromFile($FileName)
  {
    $this->String = file_get_contents($Filename);
    $Values = explode("|", $this->String);
    $this->HostName = $Values[0];
    $this->UserName = $Values[1];
    $this->Password = $Values[2];
    $this->Database = $Values[3];
  }
}

守则:

$ConnectionString = new ConnectionString();
$FileName = "db.conf";
$ConnectionString->LoadFromFile($FileName);
print( <p>Connection Info:   . $Connection->String .  </p> );

在<代码>上出现一处错误的Im file_get_contents($Filename)上称:Filename不能空出<>。 如果我用硬码表示,档案名称代替零美元,那么我就拿到所有空洞。

我没有哪一个简单的概念?

最佳回答

You ve got the case wrong:

file_get_contents($Filename);

应当

file_get_contents($FileName);

您请查阅通知,无论是在您的网址上,还是使用/error_ reporting()。

问题回答

购买力平价中的变数对个案敏感。 页: 1 关于购买力平价变量的更多信息:

http://www.php.net/manual/en/English.variables.basics.php

您今后可以做一些事情来避免这一问题:

  • Use an IDE, such as Eclipse PDT, that support auto-completion of variables.
  • Configure error_reporting to display all types of errors (E_ALL).

3. 可变案件敏感性:

function LoadFromFile($FileName)
{
   $this->String = file_get_contents($Filename); // This should be $FileName!
$this->String = file_get_contents($FileName);

页: 1 姓名:<>。

 $this->String = file_get_contents($Filename);

在这一行文上,你写了Filen美分,应当是FileN





相关问题
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 ...