The SplObjectStorage::attach() function is an inbuilt function in PHP which is used to add objects into the SplObjectStorage.
void SplObjectStorage::attach($obj, $val)
Parameters: This function accepts two parameters as mention above and described below.
- $obj: This is required parameter which specifies the object of the storage class.
- $val: This is an optional parameter which specified the values to be added.
Return Value: This function does not returns any value.
Below programs illustrate the SplObjectStorage::attach() function in PHP:
NULL string(3) "GFG" string(13) "GeeksforGeeks" NULL
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.