Category Archives: 工作

記錄工作時候,有關的東西

如何優化網頁

嗯嗯~”優化網頁”這是一個老項目了(不是SEO) 一般來說不外乎使用cache,減少inline css使用,優化js等等,一大堆技巧 (不過嘛,現今的瀏覽器,機器,頻寬那麼利害~不跑flash,javascript等。 瓶頸也不在client這邊) 回歸正題~Yahoo很貼心的列出一堆常用的技巧 http://developer.yahoo.com/performance/rules.html 測試網頁效能,firefox可以使用Firebug+Google的pagespeed,或是Yahoo的YSlow。 http://getfirebug.com/ http://code.google.com/speed/page-speed/ Chrome也有,參考這篇: http://clay0529.blogspot.com/2009/12/chrome-extension-speed-tracker.html Chrome

php上載大容量檔案時的設定

Google了一下, php預設設定只支援2MB以下大小的檔案。 要上載更大檔案時,必須修改php.ini。 以下這篇文章有提及設定方法~ http://www.radinks.com/upload/config.php (沒看完,待補完。一直在用form upload+AJAX+iframe)

php的endif endwhile格式

寫了這麼久php,還是第一次看到endif endwhile這一種格式 (剛剛在查看某wordpress template時看到) 於是就google看看 原來這款格式是php3時候就有了,格式如下 if ($foo): echo “yep\n”; elseif ($bar): echo “almost\n”; else: echo “nope\n”; endif; 除此之外,還有endwhile / endswitch等等~ (想看詳細doc的,請到source中的php.net連結) source: http://www.phpbuilder.com/manual/en/migration.if-endif.php http://docs.php.net/manual/control-structures.alternative-syntax.php

OsCommerce 的session系統

OsC這一套系統可以說是古董(2.2還support php3的說 = =) 它的session系統是自建的(以php4的session結構上再加建,php3的話就全寫) 因為太舊的關係(legacy coding),使它的session非常不好用 pass variable變得混亂 e.g. 要存寫session就要這樣做 tep_session_register(‘variable1′) $variable1=’content to store’ 那osc就會把東西存到session了 使用tep_session_register()後, osc會建立一個 global variable給你直接修改 variable的內容, 相對的是這些global variable會使建構變得很混亂 讀取的話,osc在application_top之後 便會把所有session的variables 放到global variables中, 通常先用tep_session_is_registered(‘variable name’)查看session variable是否存在 p.s.1 要integrate的話,原廠來的session name是oscid 不能夠直接用session_start() + $_session[‘var_name’] access p.s.2 php5中,session的寫法是$_session[‘var_name’]=content php4中是 session_register(‘var_name’); $var_name=content