ホームページ >php教程 >php手册 >PHP 初心者向けの 5 つの開始プログラム

PHP 初心者向けの 5 つの開始プログラム

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBオリジナル
2016-06-13 12:36:34999ブラウズ

PHP の基本的な構文形式は C の構文形式に似ています。C を学んだことがない友人でも、他の人のソース コードがどのように記述されているかを数分見てみれば、基本的にその形式に慣れるでしょう。
----------------------------------------------- -- -----
本題に入ります
用意したプログラムは 5 つです:
1. 基本的な関数を使用します。結果は文字列の形式で、echo で表示します
2. 美しいフォームを表示します
3. フォームのサンプルを送信し、送信結果を表示します
4. データベース操作のサンプル (投票プログラム)
5. サンプルを動的に作成します
--- ----- -------------------------------------- --
#プログラム 1 :
/* 機能:PHP および APACHE の設定環境と各種パラメータ変数を表示*/
echo phpinfo();/* P​​HP には豊富な関数ライブラリと便利な機能を多数搭載 作業効率が大幅に向上します。 phpinfo() は関数の 1 つです*/
?> - --------------------
#プログラム 2:
/* 機能: 美しいテーブルを表示
;HEAD>
<br></HEAD> { <br>/* <br>** 最後のカラータグを覚えておいてくださいused <br>*/ <br>static $ColorValue; <br>/* 次の色を選択します */ <br>if($ColorValue == "#00FF00") <br>{ <br>$ColorValue = "# CCFFCC"; <br>} <br>else <br>{ <br>$ColorValue = "#00FF00"; <br>} <br>return($ColorValue); <br>} <br>print "< TABLE WIDTH="100%"> "; <br>for($count=0; $count > 6; $count ) <br>{ <br>/* <br>** 現在の色を取得しますrow <br>*/ <br>$RowColor = useColor(); <br>/* <br>** 背景色に HTML 言語を使用します <br>** テーブルのセル <br>*/ <br> print "<TR><TD BGCOLOR='$RowColor'>"; <br>print "<FONT SIZE=2><CENTER>行数 $count</CENTER></FONT>< ;/TD></TR> "; <br>} <br>print "</TABLE> "; <br>?> <br></body> <br></html> 🎜>--------------------------------- --------------- --- <br>#例 3 <br><? <BR>if($send) <BR>{ <BR>echo "結果を送信します:$send"; <BR>exit; 🎜>?> <br><html> <br><body> <br><form action=<?echo $PHP_SELF?> post> <br> <input type=text name=="入力値"> <br> <input type=reset> <br></body> <br></html> <br>-------------- --------------- ---------- <br>#例4: 投票手順 <br>こちら:http://www.21php.com/forums/showthread.php ?s=&threadid=524 <br>#例 5: グラフィックを動的に作成して保存する <br><?//GD ライブラリのサポートが必要 <br> Header("Content-type:image/jpeg"); $im=imagecreate(400,30); <br>$black=ImageColorAllocate($im,0,0,0); <br>$white=ImageColorAllocate($im,255,255,255); 20,0,10,20,$white,"c:windowsfontsRaavi.ttf","私はキンターです"); <br>ImageJpeg($im, "hello.jpeg"); <br>?> <br></p></div><div class="nphpQianMsg"><div class="clear"></div></div><div class="nphpQianSheng"><span>声明:</span><div>この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。</div></div></div><div class="nphpSytBox"><span>前の記事:<a class="dBlack" title="PHP がデータベースに保存されたデータの文字化けの問題を解決する方法" href="https://m.php.cn/ja/faq/210688.html">PHP がデータベースに保存されたデータの文字化けの問題を解決する方法</a></span><span>次の記事:<a class="dBlack" title="PHP がデータベースに保存されたデータの文字化けの問題を解決する方法" href="https://m.php.cn/ja/faq/210696.html">PHP がデータベースに保存されたデータの文字化けの問題を解決する方法</a></span></div><div class="nphpSytBox2"><div class="nphpZbktTitle"><h2>関連記事</h2><em><a href="https://m.php.cn/ja/article.html" class="bBlack"><i>続きを見る</i><b></b></a></em><div class="clear"></div></div><ins class="adsbygoogle" style="display:block" data-ad-format="fluid" data-ad-layout-key="-6t+ed+2i-1n-4w" data-ad-client="ca-pub-5902227090019525" data-ad-slot="8966999616"></ins><script> (adsbygoogle = window.adsbygoogle || []).push({}); </script><ul class="nphpXgwzList"><li><b></b><a href="https://m.php.cn/ja/faq/92233.html" title="Windows7系统下Netbeans+PHPUnit搭建PHP单元测试开发环境及PHPUn" class="aBlack">Windows7系统下Netbeans+PHPUnit搭建PHP单元测试开发环境及PHPUn</a><div class="clear"></div></li><li><b></b><a href="https://m.php.cn/ja/faq/97151.html" title="程序猿ProMonkey V2.03" class="aBlack">程序猿ProMonkey V2.03</a><div class="clear"></div></li><li><b></b><a href="https://m.php.cn/ja/faq/94770.html" title="PHP Navigator" class="aBlack">PHP Navigator</a><div class="clear"></div></li><li><b></b><a href="https://m.php.cn/ja/faq/90182.html" title="php返回数组中指定的一列(php5.5.0默认函数array_column()在php" class="aBlack">php返回数组中指定的一列(php5.5.0默认函数array_column()在php</a><div class="clear"></div></li><li><b></b><a href="https://m.php.cn/ja/faq/208396.html" title="htmlentitiesとhtmlspecialcharsの違いの詳しい説明" class="aBlack">htmlentitiesとhtmlspecialcharsの違いの詳しい説明</a><div class="clear"></div></li></ul></div></div><ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-5902227090019525" data-ad-slot="5027754603"></ins><script> (adsbygoogle = window.adsbygoogle || []).push({}); </script><footer><div class="footer"><div class="footertop"><img src="/static/imghwm/logo.png" alt=""><p>福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!</p></div><div class="footermid"><a href="https://m.php.cn/ja/about/us.html">私たちについて</a><a href="https://m.php.cn/ja/about/disclaimer.html">免責事項</a><a href="https://m.php.cn/ja/update/article_0_1.html">Sitemap</a></div><div class="footerbottom"><p> © php.cn All rights reserved </p></div></div></footer><script>isLogin = 0;</script><script type="text/javascript" src="/static/layui/layui.js"></script><script type="text/javascript" src="/static/js/global.js?4.9.47"></script></div><script src="https://vdse.bdstatic.com//search-video.v1.min.js"></script><link rel='stylesheet' id='_main-css' href='/static/css/viewer.min.css' type='text/css' media='all'/><script type='text/javascript' src='/static/js/viewer.min.js?1'></script><script type='text/javascript' src='/static/js/jquery-viewer.min.js'></script><script>jQuery.fn.wait = function (func, times, interval) { var _times = times || -1, //100次 _interval = interval || 20, //20毫秒每次 _self = this, _selector = this.selector, //选择器 _iIntervalID; //定时器id if( this.length ){ //如果已经获取到了,就直接执行函数 func && func.call(this); } else { _iIntervalID = setInterval(function() { if(!_times) { //是0就退出 clearInterval(_iIntervalID); } _times <= 0 || _times--; //如果是正数就 -- _self = $(_selector); //再次选择 if( _self.length ) { //判断是否取到 func && func.call(_self); clearInterval(_iIntervalID); } }, _interval); } return this; } $("table.syntaxhighlighter").wait(function() { $('table.syntaxhighlighter').append("<p class='cnblogs_code_footer'><span class='cnblogs_code_footer_icon'></span></p>"); }); $(document).on("click", ".cnblogs_code_footer",function(){ $(this).parents('table.syntaxhighlighter').css('display','inline-table');$(this).hide(); }); $('.nphpQianCont').viewer({navbar:true,title:false,toolbar:false,movable:false,viewed:function(){$('img').click(function(){$('.viewer-close').trigger('click');});}}); </script></body><!-- Matomo --><script> var _paq = window._paq = window._paq || []; /* tracker methods like "setCustomDimension" should be called before "trackPageView" */ _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); (function() { var u="https://tongji.php.cn/"; _paq.push(['setTrackerUrl', u+'matomo.php']); _paq.push(['setSiteId', '9']); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s); })(); </script><!-- End Matomo Code --></html>