Return to Snippet

Revision: 55892
at February 27, 2012 11:38 by safe1981


Updated Code
<?php
	/**************************/
	//배열선언방법
	/**************************/
	$entry = array('Sample Title','April 13,2009', 'Jason');
	echo $entry[0], ' by ', $entry[2];
	//Sample Title by Jason 이 출력됨

	/**************************/
	//다른 방식의 배열선언(Key,Value 스타일)
	/**************************/
	$entry2 = array(
		'title' => 'Sample Title',
		'date' => 'April 13,2009'
	);
	echo $entry['title']; //ê²°ê³¼: Sample Title

	/**************************/
	//문자열 결합(String Concatenation) - period(.)으로 연결
	/**************************/
	$foo = "This is a " . "string.!";
	echo $foo;	

	/**************************/	
	//Echo출력방식 쌍따옴표,홑따옴표에 따라 달라짐
	/**************************/
	$test = "abcde";	
	echo "hello world $test"; //ê²°ê³¼:hello world abcde
	echo 'hello world $test'; //ê²°ê³¼:hello world $test

	/**************************/
	//echo를 이용하여 배열 출력하기, 중괄호({})를 사용하지 않는 경우에는 
	//인덱스에 홑따옴표가 없는 것에 주의
	/**************************/
	$person = array('name' => 'Jason', 'age'=>23);
	echo "This Person's name is {$person['name']} and he is $person[age]";

	/**************************/
	//printf사용구문
	/**************************/
	$amt1 = 2.55;
	$amt2 = 3.55;
	$total = $amt1 + $amt2;
	$string = "변수입니닷.";
	
	echo "총 가격은 $",$total, "<br />";
	printf("총 가격은 $%.2f <br />", $total); //포맷팅 용도로 활용가능
	printf("문자열 변수로 입력가능 %s", $string);	

/>

Revision: 55891
at February 27, 2012 11:38 by safe1981


Updated Code
<?php
	/**************************/
	//배���방�
	/**************************/
	$entry = array('Sample Title','April 13,2009', 'Jason');
	echo $entry[0], ' by ', $entry[2];
	//Sample Title by Jason � �력�

	/**************************/
	//�른 방�� 배���(Key,Value ���)
	/**************************/
	$entry2 = array(
		'title' => 'Sample Title',
		'date' => 'April 13,2009'
	);
	echo $entry['title']; //ê²°ê³¼: Sample Title

	/**************************/
	//문�� 결�(String Concatenation) - period(.)�� �결
	/**************************/
	$foo = "This is a " . "string.!";
	echo $foo;	

	/**************************/	
	//Echo�력방� ����,����� �� ���
	/**************************/
	$test = "abcde";	
	echo "hello world $test"; //ê²°ê³¼:hello world abcde
	echo 'hello world $test'; //ê²°ê³¼:hello world $test

	/**************************/
	//echo를 ���� 배� �력�기, ���({})를 ���� �� 경��� 
	//���� ����� �� �� 주�
	/**************************/
	$person = array('name' => 'Jason', 'age'=>23);
	echo "This Person's name is {$person['name']} and he is $person[age]";

	/**************************/
	//printf��구문
	/**************************/
	$amt1 = 2.55;
	$amt2 = 3.55;
	$total = $amt1 + $amt2;
	$string = "�����.";
	
	echo "� �격� $",$total, "<br />";
	printf("� �격� $%.2f <br />", $total); //�맷� ��� ����
	printf("문�� ��� �력�� %s", $string);	

/>

Revision: 55890
at February 27, 2012 11:37 by safe1981


Initial Code
<?php
	/**************************/
	//배열선언방법
	/**************************/
	$entry = array('Sample Title','April 13,2009', 'Jason');
	echo $entry[0], ' by ', $entry[2];
	//Sample Title by Jason 이 출력됨

	/**************************/
	//다른 방식의 배열선언(Key,Value 스타일)
	/**************************/
	$entry2 = array(
		'title' => 'Sample Title',
		'date' => 'April 13,2009'
	);
	echo $entry['title']; //ê²°ê³¼: Sample Title

	/**************************/
	//문자열 결합(String Concatenation) - period(.)으로 연결
	/**************************/
	$foo = "This is a " . "string.!";
	echo $foo;	

	/**************************/	
	//Echo출력방식 쌍따옴표,홑따옴표에 따라 달라짐
	/**************************/
	$test = "abcde";	
	echo "hello world $test"; //ê²°ê³¼:hello world abcde
	echo 'hello world $test'; //ê²°ê³¼:hello world $test

	/**************************/
	//echo를 이용하여 배열 출력하기, 중괄호({})를 사용하지 않는 경우에는 
	//인덱스에 홑따옴표가 없는 것에 주의
	/**************************/
	$person = array('name' => 'Jason', 'age'=>23);
	echo "This Person's name is {$person['name']} and he is $person[age]";

	/**************************/
	//printf사용구문
	/**************************/
	$amt1 = 2.55;
	$amt2 = 3.55;
	$total = $amt1 + $amt2;
	$string = "변수입니닷.";
	
	echo "총 가격은 $",$total, "<br />";
	printf("총 가격은 $%.2f <br />", $total); //포맷팅 용도로 활용가능
	printf("문자열 변수로 입력가능 %s", $string);	

/>

Initial URL

                                

Initial Description
PHP에서 사용하기 위한 기본문법

Initial Title
PHP Basic Syntax

Initial Tags

                                

Initial Language
PHP