<?php
class Word {
public function __construct($single_word) {
$this->single_word = $single_word;
}
public function __concat_str($str, $side = false, $space = false) {
if($space === true) {
$space = ' ';
} else {
$space = '';
}
if($side === true) {
return $str.$space.$this->single_word;
} else {
return $this->single_word.$space.$str;
}
}
public function __set_color($col, $string) {
return "<span style='color:$col;'>".$string."</span>";
}
}
function concat_str($concatenate_word, $string, $color = 'black', $allo1 = true, $allo2 = true) {
$my_method1 = $concatenate_word->__concat_str($string, $allo1, $allo2);
$my_method2 = $concatenate_word->__set_color($color, $my_method1);
return $my_method2;
}
$concatenate_word = new Word('fish');
echo concat_str
($concatenate_word, 'HELLO', 'orange');
$concatenate_word = new Word('apple');
echo concat_str
($concatenate_word, 'I see', 'pink');
$concatenate_word = new Word('sand');
echo concat_str
($concatenate_word, 'I reclined on the', 'gold')."<br />"; echo concat_str
($concatenate_word, 'I reclined on the', 'gold')."<br />"; echo concat_str
($concatenate_word, 'I reclined on the', 'gold')."<br />"; echo concat_str
($concatenate_word, 'I reclined on the', 'gold')."<br />"; echo concat_str
($concatenate_word, 'I reclined on the', 'gold')."<br />"; $concatenate_word = new Word('beach');
echo concat_str
($concatenate_word, 'I reclined on the', 'gold')."<br />"; echo concat_str
($concatenate_word, 'I reclined on the', 'lime')."<br />";
?>