Skip to content

2. print문으로 문자열 출력하기 #56

@JoisFe

Description

@JoisFe

Discussed in https://github.com/orgs/Programming-Language-Practice/discussions/55

Originally posted by JoisFe February 25, 2023

2. print문으로 문자열 출력하기

  • 출력문에는 echo 외에 print문도 존재 (사용 방법은 echo문과 같음)

print문 사용하여 문자열 출력 방법

  1. 큰따옴표 사용
print "문자열";
  1. 작은 따옴표 사용
print "문자열";

print문 사용하여 숫자만 출력하는 방법

  1. 숫자 1을 출력
print 1;
  1. 숫자 1234를 출력하는 경우
print 1234;
  1. 문자열 속에 숫자가 있는 경우 (따옴표 사용)
print "PHP 해보자!!"

예시

<?php
    print "하이";
    print '<br>';
    print '반갑';
    print "<br>";
    print 1234;
    print '<br>';
    print "1234";
?>
image

문제 상황

큰 따옴표로 시작하여 작은따옴표로 끝나거나 그 반대면 작동하지 않음

print "PHP 해보자!!'
print 'PHP 해보자!!"

Reference

초보자를 위한 PHP 200제, 정보문화사, [김태영]

Metadata

Metadata

Assignees

No one assigned

    Labels

    200 Solved초보자를 위한 200제 책 학습을 위한 라벨입니다.PHPPHP 관련 라벨입니다.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions