Jump to content

Recommended Posts

Everything is possible in its own work around. Here is an example of overloading a function in PHP

 

<?php

class a {

function a() {
	// constructor
	$this->b = new b();
}


function overLoad() {
	// extra data here

	return $this->b->overLoad() "!!!";
}

}

class b {

function b() {
	// constructor
}


function overLoad() {
	// extra data here

	return "The cat is fat";
}

}
?>

 

 

Another alternative might be this (I have not tested this)

 

<?php

class a extends b {

function a() {
	// constructor
}


function overLoad() {
	// extra data here

	return b::overLoad() . "!!!";
}

}

class b {

function b() {
	// constructor
}


function overLoad() {
	// extra data here

	return "The cat is fat";
}

}
?>

 

 

Now as for processing time for the first one, it should not be too bad for 1 class etc. But if you have 5 classes you are trying to do that to, your processing time increases dramatically. I am not sure what the second one result is.

 

Either way if you test it out let us know what you find.

 

--FrosT

Link to comment
https://forums.phpfreaks.com/topic/42019-function-overloading/#findComment-203780
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.