Dynadot โ€” .com Transfer

OOP Sharing Values

SpaceshipSpaceship
Watch

blacksnday

Established Member
Impact
1
I was wondering how to share values between one class and an extension of it, where the value would first be assigned by the main class and be used by the extension after being assigned?

if that confuses you, here is an example of what I am trying to do:

PHP:
class SomeClass {

function someFunction($assign_me=' '){

$assign_me == FALSE ? $assign_me = ' ' : $assign_me = "IMASSIGNED";
}

}

class AnotherClass extends SomeClass{

function isAssigned(){
if($assign_me = "IMASSIGNED"){
echo "It Has Been Assigned";
}

}
}
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
blacksnday said:
I was wondering how to share values between one class and an extension of it, where the value would first be assigned by the main class and be used by the extension after being assigned?

if that confuses you, here is an example of what I am trying to do:

PHP:
class SomeClass {

function someFunction($assign_me=' '){

$assign_me == FALSE ? $assign_me = ' ' : $assign_me = "IMASSIGNED";
}

}

class AnotherClass extends SomeClass{

function isAssigned(){
if($assign_me = "IMASSIGNED"){
echo "It Has Been Assigned";
}

}
}

personaly i'm not sure, but the if($assign_me = "IMASSIGNED") in the extended bit is going to be messing up your testing, as the = will be assigning the vaule, not checking it like ==/=== does
 
0
•••
PHP:
class SomeClass { 
var $bla ='';
function someFunction($assign_me=' '){ 

$assign_me == FALSE ? $this->bla = ' ' : $this->bla= "IMASSIGNED"; 
} 

} 

class AnotherClass extends SomeClass{ 

function isAssigned(){ 
if($this->bla = "IMASSIGNED"){ 
echo "It Has Been Assigned"; 
} 

} 
}

I think is what u need
 
0
•••
Appraise.net
Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomDB
NameFit
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back