Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #8226

Re: classes in PHP

From Jerry Stuckle <jstucklex@attglobal.net>
Newsgroups comp.lang.php
Subject Re: classes in PHP
Date 2013-02-04 00:07 -0500
Organization A noiseless patient Spider
Message-ID <kenfm0$4qa$1@dont-email.me> (permalink)
References <fd3565a9-3766-4224-bed5-812a0cd11d64@googlegroups.com> <c42bd135-6e8f-46e3-be37-445b423ff529@googlegroups.com> <an7p7gF2ktvU1@mid.uni-berlin.de>

Show all headers | View raw


On 2/3/2013 1:39 PM, M. Strobel wrote:
> Am 03.02.2013 18:49, schrieb Rita Ferreira:
>> Hi,
>> thanks for reply.
>> The error I'm obtained is:
>>
>> Fatal error: Class 'config' not found in /Applications/MAMP/htdocs/admin_classes/UserController.php on line 10
>>
>> UserController.php
>>
>> <?php
>>
>> error_reporting(E_ALL);
>> ini_set('display_errors', '1');
>>
>> class UserController
>> {
>> 	
>> 	private $obj;
>>
>> 	function __construct( ){}
>>
>> 	public function login()
>> 	{
>> 		if($_SERVER["REQUEST_METHOD"] == "POST")
>> 		{
>> 			$obj=new config();
>> 			$obj->conectar();
>>                  }
>>          (..)
>>          }
>> }
>>
>> config.php
>>
>> <?php
>>
>> private $url_db;
>> private $login_db;
>> private $pass_db;
>> private $db;
>>
>> class config
>> {
>>
>> 	function __construct( )
>>      {
>>          session_start();
>>          $url_db="localhost";
>>          $login_db="root";
>>          $pass_db="root";
>>          $db="colmeia";
>>      }
>
> Please put your answer below the text. You are in the "usenet", read about it, and
> use a news reader if you can.
>
> The message says it all: class config is unknown. You must use
> include/include_once/require/require_once to pull the definitions in.
>
> You would never start a session somewhere inside the code, session_start() is the
> first thing to do.
>
> /Str.
>

Almost... If you have a class object in the session, you need to include 
or require the class object first.

Generally, in require_once() the necessary class code, *then* call 
session_start().


-- 
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

classes in PHP Rita Ferreira <ritaferreira83@gmail.com> - 2013-02-03 09:04 -0800
  Re: classes in PHP "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2013-02-03 18:11 +0100
  Re: classes in PHP Rita Ferreira <ritaferreira83@gmail.com> - 2013-02-03 09:49 -0800
    Re: classes in PHP "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2013-02-03 19:39 +0100
      Re: classes in PHP Jerry Stuckle <jstucklex@attglobal.net> - 2013-02-04 00:07 -0500
      Re: classes in PHP Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-02-06 13:29 +0100
        Re: classes in PHP Jerry Stuckle <jstucklex@attglobal.net> - 2013-02-06 08:49 -0500
        Re: classes in PHP "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2013-02-07 11:57 +0100
          Re: classes in PHP Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-02-07 12:17 +0100
          Re: classes in PHP Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-02-07 12:35 +0100
          Re: classes in PHP The Natural Philosopher <tnp@invalid.invalid> - 2013-02-07 11:46 +0000
            Re: classes in PHP "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2013-02-07 14:46 +0100
    Re: classes in PHP Simon <bad@example.com> - 2013-02-04 09:15 +0200

csiph-web