English 中文(简体)
在PHP中,在我的职责的最后几个字节上保留了辛加错误。
原标题:Keep getting syntax error at the final bracket of my function in PHP

I m试图书写为一年级学生创建的一种方法,该方法被分配到_orm(),接受单一论点,即学生。

这种方法应当做到两点:

Check to see if the number of items in the occupants property array is equal to or greater than the capacity property. If so, return FALSE. If not, take the student object, and add it as an item in the occupants property array.

<?php

class Dorm
{
    private $dorm_name;
    private $capacity;
    private $occupants = array();


   public function assign_to_dorm(Student)
   {
       $ammount = count($occupants);

       if($ammount >= $capacity)
       {
            return FALSE;
       } 


    } //    <---------------  KEEP GETTING ERRORS HERE
}

?>
问题回答
public function assign_to_dorm(Student)
                               ^^^^^^^---- bare word

你的直截了当,没有工作。 它应当是可变和/或可变的加类。

  public function assign_to_dorm($student) //proper variable syntax
   {
       $ammount = count($this->occupants);
       if($ammount >= $this->capacity)  //access members via $this->member_name
       {
            return FALSE;
       } 
    } // 

您的职能定义有2个错误:

  • 页: 1

  • 班级成员应具备以下资格:$this.$occupants,这是职能范围界定的一个地方变量,$this->occupants为班级成员。

A. 初看 在你关于分配_to_dorm的论点清单中,你只是提供学生,即学生。 学生学习费,或只是学生费。





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

热门标签