"PHP 배치 전달인자 받기"의 두 판 사이의 차이

잔글 (봇: 자동으로 텍스트 교체 (-source +syntaxhighlight))
 
(사용자 2명의 중간 판 21개는 보이지 않습니다)
1번째 줄: 1번째 줄:
==개요==
==개요==
;PHP 스크립트 전달인자 받기
;PHP 배치 인수 받기
;PHP 배치 인수 받기
;PHP 인자 전달


<source lang='dos'>
<syntaxhighlight lang='console'>
root@zetawiki:~# cat greet.php
<?php
<?php
if(count($argv)<2) {
if(count($argv)<2) {
$php_file = $argv[0];
$php_file = $argv[0];
echo "$php_file: missing operand\n";
echo "Error in $php_file: missing argument.\n";
exit(1);
exit(1);
}
}
</source>
echo "Hello, ".$argv[1].".\n";
 
</syntaxhighlight>
==같이 보기==
<syntaxhighlight lang='console'>
*[[PHP 배치]]
root@zetawiki:~# php greet.php
 
Error in greet.php: missing argument.
[[분류: PHP]]
root@zetawiki:~# php greet.php John
Hello, John.
root@zetawiki:~# php greet.php John Smith
Hello, John.
root@zetawiki:~# php greet.php 'John Smith'
Hello, John Smith.
</syntaxhighlight>


==같이 보기==
==같이 보기==
*[[PHP 배치]]
*[[PHP 배치]]
*[[PHP 배치 옵션 받기]]
*[[Python 인자 전달]]
*[[Ruby 인자 전달]]
*[[전달인자]] (argument)


[[분류: PHP]]
[[분류: PHP]]

2020년 11월 2일 (월) 02:35 기준 최신판

1 개요[ | ]

PHP 스크립트 전달인자 받기
PHP 배치 인수 받기
PHP 인자 전달
root@zetawiki:~# cat greet.php 
<?php
if(count($argv)<2) {
	$php_file = $argv[0];
	echo "Error in $php_file: missing argument.\n";
	exit(1);
}
echo "Hello, ".$argv[1].".\n";
root@zetawiki:~# php greet.php 
Error in greet.php: missing argument.
root@zetawiki:~# php greet.php John
Hello, John.
root@zetawiki:~# php greet.php John Smith
Hello, John.
root@zetawiki:~# php greet.php 'John Smith'
Hello, John Smith.

2 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}