Home  >  Article  >  Backend Development  >  The first javascript program developed by php

The first javascript program developed by php

WBOY
WBOYOriginal
2016-08-08 09:26:161150browse

I won’t talk about the basic concepts here. I typed out my first javasript program according to the code in the book, which is my own hello world. It is a great encouragement to myself. I will post the code below and let everyone learn together.
index.php

<code><span><span><?php</span>header(<span>'Content-type:text/html'</span>);
<span>include</span><span>'test.html'</span>;


<span>?></span></span></code>

test.html

<code><span><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"></span><span><<span>html</span>></span><span><<span>head</span>></span><span><<span>meta</span><span>http-equiv</span>=<span>"Content-Type"</span><span>content</span>=<span>"text/html; charset=GB18030"</span>></span><span><<span>script</span><span>type</span> =<span>"text/javascript"</span>></span><span><span><span>function</span><span>cubeme</span><span>(incomingNum)</span>{</span><span>if</span>(incomingNum ==<span>1</span>){
        <span>return</span><span>"what are you doing ?"</span>;
    }<span>else</span>{
        <span>return</span><span>Math</span>.pow(incomingNum,<span>3</span>);
    }
}

</span><span></<span>script</span>></span><span><<span>title</span>></span>JavaScript Test<span></<span>title</span>></span><span></<span>head</span>></span><span><<span>body</span>></span><span><<span>script</span><span>type</span> =<span>"text/javascript"</span>></span><span><span>var</span> theNum =<span>2</span>;
<span>var</span> finalNum =cubeme(theNum);
<span>if</span>(<span>isNaN</span>(finalNum)){

    alert(<span>"You should know that 1 to any power is 1."</span>);
}
<span>else</span>{
    alert(<span>"when cubed ,"</span> + theNum + <span>"is"</span> + finalNum);
}

</span><span></<span>script</span>></span><span></<span>body</span>></span><span></<span>html</span>></span></code>

The running results are as follows:

The above introduces the first JavaScript program for PHP development, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:php backup databaseNext article:php backup database