//interface interface Ingredient { function createSugar(); function createCream(); function createMilk(); } // ingredient class SeoulIngredient implements Ingredient { function createSugar() { return new blackSugar(); } function createCream() { return new Cream(); } function createMilk() { return new Milk(); } } class JejuIngredient implements Ingredient { function createSugar() { echo "Jeu Suga..
interface Duck { function quick(); function fly(); } class JDuck implements Duck { function quick() { echo "Quick"; } function fly() { echo "Fly"; } } interface Chil { function goole(); function fly(); } class JChil implements Chil { function goole() { echo "GGGGGGG~~~~~"; } function fly() { echo " -|- "; } } class DuckApter implements Duck { public $_chil; function __construct($chil) { $this->_..
시간 계산 참고 // Date A : 2010-12-20 14:00:00 // Date B : 2010-12-20 13:00:00 //시간 출력 01:00:00 var dateA = new Date(2010,12,21,14,6,10 ); var dateB = new Date(2010,12,20,13,0,0 ); var dateC = +new Date(); /* dbTime.setFullYear(2010); dbTime.setMonth(11); // 0 ~ 11 dbTime.setDate(21); dbTime.setHours(14); dbTime.setMinutes(26); dbTime.setSeconds(0); */ //var dbTime = new Date(2010,11,21, 14, 26, 0); /..
레퍼런스로 리턴하기 지 난 칼럼에서는 PHP에서 여러 값을 리턴하기 위해 레퍼런스를 함수의 파라미터로 사용하는 방법에 대해 살펴보았다. 이번 칼럼에서는 레퍼런스를 실제 리턴값으로 사용하는 것에 대해 알아보고 이것이 개발자에게 얼마나 유용한지를 알아 볼 것이다. 이번 기사를 위해 다음과 같은 클래스를 만들었다. 위 코드에서 보다시피 A와 B라는 간단한 두 개의 클래스를 생성했다. 그리고 각각은 printmsg()라는 함수 하나만을 포함하고 있다. 그리고 나서, 각 클래스의 인스턴스를 생성했고 $toobox라 는 배열에 저장을 하였다. 우선 위의 것은 넘어가고, 레퍼런스 함수를 통해 전달하는 것부터 알아보자. 여러 곳에서 레퍼런스 함수에 의한 리턴이 쓰일 수 있지만, 여기서 생성할 함수는 오직 하나의 파라미..
가끔 PHP로 웹페이지를 작성할 일이 있는데, 유용한 팁을 우연히 보게 되어 한글로 옮겨적어본다. 원본은 40 Tips for optimizing your php Code 1. If a method can be static, declare it static. Speed improvement is by a factor of 4. 메쏘드가 static이 될 수 있다면 static으로 선언하라. 4배 빨라진다. 2. echo is faster than print. echo가 print보다 빠르다. 3. Use echo’s multiple parameters instead of string concatenation. 문자열을 이어붙이지 말고, echo를 이용하여 여러 개의 파라미터를 적어라. 4. Set the..