使用sqlite
sudo apt-get install php5-sqlite
win環境下瀏覽sqlite資料庫的工具
http://sqlitebrowser.org/
可下載 portable免安裝版
2017年6月18日 星期日
php基本表單
建立一個php程式 t1_post1.php
<form action="t1_post2.php" method="post">
姓名: <input type="text" name="urname" /> <br>
密碼: <input type="password" name="urpass" /><br>
<input type="submit" value="送出表單"/>
</form>
建立第2個php程式 t1_post2.php
<?php
if ($_POST["urname"] <>'') {
echo '你的名字'.$_POST["urname"].'<br>';
echo '你的密碼'.$_POST["urpass"];
}
else {
echo '非法留言';
}
<form action="t1_post2.php" method="post">
姓名: <input type="text" name="urname" /> <br>
密碼: <input type="password" name="urpass" /><br>
<input type="submit" value="送出表單"/>
</form>
建立第2個php程式 t1_post2.php
<?php
if ($_POST["urname"] <>'') {
echo '你的名字'.$_POST["urname"].'<br>';
echo '你的密碼'.$_POST["urpass"];
}
else {
echo '非法留言';
}
-----------------------------------------------------
加入css風格
建立一個目錄static 裡面建立style.css檔案(常用的css語法寫入)
body { text-align:left;font-family: sans-serif; background: #eee; }
a, h1, h2 { color: #377ba8; }
h1, h2 { font-family: 'Georgia', serif; margin: 0; }
h1 { border-bottom: 2px solid #eee; }
h2 { font-size: 1.2em; }
.page { margin: 2em auto; width: 55em; border: 5px solid #ccc;
padding: 0.8em; background: white; }
---------------------------------
t1_post1.php 程式修改成以下(先引入 style.css,div class 呼叫風格)
<link rel="stylesheet" href="static/style.css" />
<div class=page>
<form action="t1_post2.php" method="post">
姓名: <input type="text" name="urname" /> <br>
密碼: <input type="password" name="urpass" /><br>
<input type="submit" value="送出表單"/>
</form>
</div>
加入css風格
建立一個目錄static 裡面建立style.css檔案(常用的css語法寫入)
body { text-align:left;font-family: sans-serif; background: #eee; }
a, h1, h2 { color: #377ba8; }
h1, h2 { font-family: 'Georgia', serif; margin: 0; }
h1 { border-bottom: 2px solid #eee; }
h2 { font-size: 1.2em; }
.page { margin: 2em auto; width: 55em; border: 5px solid #ccc;
padding: 0.8em; background: white; }
---------------------------------
t1_post1.php 程式修改成以下(先引入 style.css,div class 呼叫風格)
<link rel="stylesheet" href="static/style.css" />
<div class=page>
<form action="t1_post2.php" method="post">
姓名: <input type="text" name="urname" /> <br>
密碼: <input type="password" name="urpass" /><br>
<input type="submit" value="送出表單"/>
</form>
</div>
Twig基本用法
apache2環境要先設定好
sudo vi /etc/php5/apache2/php.ini
把short_open_tag = Off
改成
short_open_tag = On
加入
extension=twig.so
/etc/init.d/apache2 restart
或
service apache2 restart
--------------------------------------------------------------
php程式 t1.php
sudo vi /etc/php5/apache2/php.ini
把short_open_tag = Off
改成
short_open_tag = On
加入
extension=twig.so
/etc/init.d/apache2 restart
或
service apache2 restart
--------------------------------------------------------------
php程式 t1.php
<?php
//include "config.php";
//twig
require_once 'lib/Twig/Autoloader.php';
Twig_Autoloader::register();
$loader = new Twig_Loader_Filesystem('templates');
$twig = new Twig_Environment($loader);
$school=['湖東','湖南','湖北'];
//多維陣列
$school2=['schoolname'=>array('湖東','湖南','湖北'),
'class'=>array('40班','30班','33班'),
'stu'=>array('800人','700人','750人'),
];
echo $twig->render('t1.html', array('name' => '台灣','year'=>66,'school'=>$school,
'school2'=>$school2 ));
樣板網頁t1.html
自己設定變數
{% set f1 = 'good' %}
呼叫變數 {{f1}} <br>
{{name}} <br>
{{year}}<br>
{% if year > 55 %}
您超過55歲 <br>
{% else %}
您小於55歲 <br>
{% endif %}
<hr>
{% for pp in school %}
學校: {{ pp }}
<br>
{% endfor %}
<hr>
{% for i in range(0, 2) %}
學校:{{school2.schoolname[i]}} <br>
班級:{{school2.class[i]}} <br>
學生:{{school2.stu[i]}} <br>
<br>
{% endfor %}
2017年2月10日 星期五
快速切換目錄shell
在linux系統裡,有時要切換到一個深層的目錄,目錄名稱打一大堆
以後執行 ./2
這時可以利用簡單得bash指令,作法如下:
建立一個指令檔,例如a2
vi a2
輸入下列指令
#!/bin/bash
cd /var/www/a1/dsw/dsd/
# start another shell and replacing the current
exec /bin/bash
存檔
更改屬性
chmod 700 a2
就能進入cd /var/www/a1/dsw/dsd/ 這個目錄了
2016年8月16日 星期二
02Lazarus實際範例第1課
第一課
學習:宣告變數、亂數種子、數值轉換字串、If條件判斷
布局:
1.面界設計一個image、一個文字標籤、一個按鈕、三張圖
2.按鈕按下去,數亂跑出1-30之間隨意一個整數
3.如果小於10就秀出圖片1;大於10小於20秀出圖片2;大於20小於30秀出圖片3
請到社團 下載範例檔
https://www.facebook.com/groups/1767834446795825/
學習:宣告變數、亂數種子、數值轉換字串、If條件判斷
布局:
1.面界設計一個image、一個文字標籤、一個按鈕、三張圖
2.按鈕按下去,數亂跑出1-30之間隨意一個整數
3.如果小於10就秀出圖片1;大於10小於20秀出圖片2;大於20小於30秀出圖片3
請到社團 下載範例檔
https://www.facebook.com/groups/1767834446795825/
01Lazarus
Lazarus是免費的程式開發工具,執行環境支援window、Linux和Mac。幾乎涵蓋
目前所有常見的作業平台,是跨平台的超強工具。
Lazarus有視覺化的IDE設計界面,方便您直接拖曳一些元件,例如按鈕、文字標籤
、影像框、對話框...等等,功能多且齊全。非常適合學校推廣程式教育。
下載網址
http://www.lazarus-ide.org/
按上面 Downloads 請下載自己作業系統的環境下的安裝檔
目前所有常見的作業平台,是跨平台的超強工具。
Lazarus有視覺化的IDE設計界面,方便您直接拖曳一些元件,例如按鈕、文字標籤
、影像框、對話框...等等,功能多且齊全。非常適合學校推廣程式教育。
下載網址
http://www.lazarus-ide.org/
按上面 Downloads 請下載自己作業系統的環境下的安裝檔
Windows
- Windows (32 and 64 Bits) Direct download
- Windows (32 Bits) Add ons
- Windows (64 Bits)
- Windows (64 Bits) Add ons
Linux
DEB Releases
RPM Releases
Mac OS X
2016年7月27日 星期三
訂閱:
文章 (Atom)