Scite 開啟 Php 本機端

lua-users home
wiki

WalterCruz 撰寫

在使用 SciTE 和 PHP 時,我很快發現一個需求:透過網路伺服器開啟我的 PHP 檔案,而不只是原樣開啟該檔案。

我嘗試撰寫一個 bash 腳本來執行此動作,但我很快就對此感到厭煩,並用 PHP 完成這項工作。

於是我開始閱讀 Lua,我想「為何不呢?」

所以,這就是結果!

function openbrowser()
	local f = props['FilePath']
	local s,e,path,file = string.find(f,'^(/var/www/)(.*)')
	if path == '/var/www/' then
		target = ("http://10.132.1.18/" .. file)
		firefox = ('mozilla-firefox ' .. target .. ' &')
		print("Opening  " .. target)
		--print(firefox)
		os.execute(firefox)
	else
		print("You must put your php files under /var/www in order to run them.")
	end	
end

我將此檔案另存新檔為 localhost.lua,載入使用我的 Lua 啟動檔案,並在 SciTE 使用者設定中加入下列行:

command.go.subsystem.*.php=3
command.go.*.php=openbrowser()

(在我的電腦上,網路伺服器根目錄是< /var/www。請注意,此目錄在您自己的電腦上可能不同)。


最新變更 · 偏好設定
編輯 · 歷程
上次編輯:2006 年 8 月 31 日 下午 8:47 GMT (diff)