Jump to content

__construct not working


onlyican

Recommended Posts

Hey guys

This is a bit strange

I been working on a large script, on my local machine

I uploaded it to my server, and was getting erorrs left right and centre

I found out that the __construct function is not running when I call the function

I thought I will double check this, so I built a dummy class.

The code is something like this

FILE: myclass.php
[code]

<?php

class test{

  function __construct(){

  echo "This is the first function, which should run automaticly<br />\n";

 

  }

 

 

  function AddedFunction(){

  echo "This function should only be called when I call it<br />\n";

  }

}

?>
[/code]
then

FILE: run.php

[code]

<html>

<head>

<title>Test Class</title>

</head>

<body>

<?php

require("myclass.php");

echo "Here, I will call start the new object for the class<br /><br />\n\n";

$dummy = new test;

echo "Now I will call the Extra Function<br /><br />\n\n";

$dummy->AddedFunction();

echo "End<br />\n";

?>

</body>

</html>
[/code]

Nothing too clever there

On my local machine, which is running PHP V 5.1.1

I get the following

[quote]

Here, I will call start the new object for the class

This is the first function, which should run automaticly

Now I will call the Extra Function

This function should only be called when I call it

End
[/quote]
Which is correct

BUT

On my server, which is running PHP V 4.4.3 I get

[quote]

Here, I will call start the new object for the class

Now I will call the Extra Function

This function should only be called when I call it

End
[/quote]
Which is missing the line from the construct function

Any ideas
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.