PHP 5.x vs PHP 7 syntax
페이지 정보
본문
* 출처
https://acaroom.net/ko/blog/youngdeok/php-5x-vs-php-7-syntax
ㅁ namespace 활용하기
[code]
<?php // lib/haruair/helloWorld.php
namespace Haruair;
class HelloWorld {
function say() {
return "HelloWorld";
}
}
?>
<?php // lib/wordpress/helloWorld.php
namespace WordPress;
class HelloWorld {
function say() {
return "HelloWorld. I'm wordpress btw.";
}
}
?>
[/code]
[code]
<?php // app.php
include_once('./lib/haruair/helloWorld.php');
include_once('./lib/wordpress/helloWorld.php');
$haruair = new Haruair\HelloWorld();
$wordpress = new WordPress\HelloWorld();
echo $haruair->say(); // HelloWorld
echo $wordpress->say(); // HelloWorld. I'm wordpress btw.
?>
[/code]
https://acaroom.net/ko/blog/youngdeok/php-5x-vs-php-7-syntax
ㅁ namespace 활용하기
[code]
<?php // lib/haruair/helloWorld.php
namespace Haruair;
class HelloWorld {
function say() {
return "HelloWorld";
}
}
?>
<?php // lib/wordpress/helloWorld.php
namespace WordPress;
class HelloWorld {
function say() {
return "HelloWorld. I'm wordpress btw.";
}
}
?>
[/code]
[code]
<?php // app.php
include_once('./lib/haruair/helloWorld.php');
include_once('./lib/wordpress/helloWorld.php');
$haruair = new Haruair\HelloWorld();
$wordpress = new WordPress\HelloWorld();
echo $haruair->say(); // HelloWorld
echo $wordpress->say(); // HelloWorld. I'm wordpress btw.
?>
[/code]
추천0
댓글목록
등록된 댓글이 없습니다.