-- Oct 19 In-Class Exercise
namespace companyX\test_project;
class StringHolder{
public $my_string;
function __construct($a_string){
$this->my_string=$a_string;
}
}
//second file
<?php
require_once('StringHolder.php');
use companyX\test_project as C;
$string_holder = new C\StringHolder("hi there");
echo $string_holder->my_string ."\n";
//Output
siddhitajoshi@Siddhitas-MacBook-Pro test_project % php test.php
hi there
(
Edited: 2022-10-19)
namespace companyX\test_project;
class StringHolder{
public $my_string;
function __construct($a_string){
$this->my_string=$a_string;
}
}
//second file
<?php
require_once('StringHolder.php');
use companyX\test_project as C;
$string_holder = new C\StringHolder("hi there");
echo $string_holder->my_string ."\n";
//Output
siddhitajoshi@Siddhitas-MacBook-Pro test_project % php test.php
hi there