๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Designer_Vibi/Programming

PHP์™€ Javascript ํ•จ์ˆ˜/์ž…๋ ฅ๊ณผ ์ถœ๋ ฅ

by PowerPurpleGal_Vibi 2019. 5. 1.
๋ฐ˜์‘ํ˜•

์‚ฌ์šฉ์ž ์ •์˜ ํ•จ์ˆ˜ ์„ ์–ธํ•˜๊ณ  ํ˜ธ์ถœํ•˜๊ธฐ

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

</head>

<body>

<h1>JavaScript</h1>

<script>

function a(){//ํ•จ์ˆ˜ ์„ ์–ธ

document.write("Hello JS Function");

}

a();//ํ•จ์ˆ˜ ํ˜ธ์ถœ

</script>

 

<h1>php</h1>

<?php

function a(){//ํ•จ์ˆ˜ ์„ ์–ธ

echo "Hello PHP Function ";

}

a();//ํ•จ์ˆ˜ ํ˜ธ์ถœ

?>

</body>

</html>

 

ํ•จ์ˆ˜์˜ ์ž…๋ ฅ๊ฐ’๊ณผ ์ถœ๋ ฅ๊ฐ’

 

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

</head>

<body>

<h1>JavaScript</h1>

 

<script>

function a(์ž…๋ ฅ๊ฐ’or๋งค๊ฐœ๋ณ€์ˆ˜ ์ด๋ฆ„์€ ๋งˆ์Œ๋Œ€๋กœ ์ง€์ •){

   document.write(input+1);

}

a(์ž…๋ ฅ๊ฐ’์— ๋“ค์–ด๊ฐˆ ๊ฐ’ ex) 1);

//์ถœ๋ ฅ 2

</script>

 

<h1>php</h1>

<?php

function a($input){

return $input+1;

}

echo a(6);

?>

</body>

</html>

<!DOCTYPE html>

document.write(a(6));

<html>

<head>

<meta charset="utf-8">

</head>

<body>

<h1>JavaScript</h1>

 

<script>

function a(input){

return input+1; //์ถœ๋ ฅ๊ฐ’

}*์•ฝ์†๋œ ๊ธฐํ˜ธ(๊ณ„์‚ฐ๋œ ๊ฐ’์„ ๋ฐ˜ํ™˜ํ•˜๋ผ)

document.write(์ถœ๋ ฅ๊ฐ’7 a(์ž…๋ ฅ๊ฐ’6));

or

prompt(a(6));

//์ถœ๋ ฅ 7

</script>

 

<h1>php</h1>

<?php

function a($input){

return $input+1;

}

echo a(6);

?>

</body>

</html>

 

 

 

 

๋ฐ˜์‘ํ˜•