Start
2023年12月14日 星期四
2023年12月4日 星期一
2023年12月1日 星期五
javascript, python
package的入口>>
js:
index.js
py:
__init__.py
-------------------------------------------
import 的差異>>
js:
impot {...} from '...'
import XX as XX from '...'
py:
import package as nickName
import dir.package
from package import component
-------------------------------------------
檔案當前路徑>>
py:
os.getcwd()
php:
$_SERVER['PHP_SELF'], __FILE__
-------------------------------------------
專案當前路徑>>
-------------------------------------------
數值類型>>
js:
typeof(...)
py:
type(...)
php:
gettype()
-------------------------------------------
undefined, null>>
js:
... == null
typeof(...) == 'undefined'
py:
... is None
php:
isset(...), empty(...), is_null(...)
-------------------------------------------
2023年11月4日 星期六
game
2023年10月20日 星期五
atom keybind
# Your keymap
#
# Pulsar keymaps work similarly to style sheets. Just as style sheets use
# selectors to apply styles to elements, Pulsar keymaps use selectors to associate
# keystrokes with events in specific contexts. Unlike style sheets however,
# each selector can only be declared once.
#
# You can create a new keybinding in this file by typing "key" and then hitting
# tab.
#
# Here's an example taken from Pulsar's built-in keymap:
#
# 'atom-text-editor':
# 'enter': 'editor:newline'
#
# 'atom-workspace':
# 'ctrl-shift-p': 'core:move-up'
# 'ctrl-p': 'core:move-down'
#
# You can find more information about keymaps in these guides:
# * https://pulsar-edit.dev/docs/launch-manual/sections/using-pulsar/#customizing-keybindings
# * https://pulsar-edit.dev/docs/launch-manual/sections/behind-pulsar#keymaps-in-depth
#
# If you're having trouble with your keybindings not working, try the
# Keybinding Resolver: `Cmd+.` on macOS and `Ctrl+.` on other platforms. See the
# Debugging Guide for more information:
# * https://pulsar-edit.dev/docs/launch-manual/sections/core-hacking/#check-your-keybindings
#
# This file uses CoffeeScript Object Notation (CSON).
# If you are unfamiliar with CSON, you can read more about it in the
# Pulsar Launch Manual:
# https://pulsar-edit.dev/docs/launch-manual/sections/using-pulsar/#configuring-with-cson
'atom-text-editor':
"ctrl-space": "unset!"
'alt-/': 'autocomplete-plus:activate'
2022年8月22日 星期一
php 命令模式(路徑問題)
// 校正命令模式的 dir
chdir(__DIR__);
function is_cli() {
if (php_sapi_name() === 'cli') {
return true;
}
if (defined("STDIN")) {
return true;
}
if (!isset($_SERVER["REMOTE_ADDR"]) || empty($_SERVER["REMOTE_ADDR"])) {
return true;
}
return false;
}
php include, require 路徑問題
PHP中include和require絕對路徑、相對路徑問題
-Advertisement-
Play Games
在寫PHP程式時,經常要用到include或require包含其他文件,但是各文件里包含的文件多了之後,就會產生路徑問題。 如下目錄: <web>(網站根目錄) ├<A>文件夾 │ │ │ └1.php ├<B>文件夾 │ │ │ └2.php └index.php 現在根目錄下的index.php ...
在寫PHP程式時,經常要用到include或require包含其他文件,但是各文件里包含的文件多了之後,就會產生路徑問題。
如下目錄:
<web>(網站根目錄)
├<A>文件夾
│ │
│ └1.php
├<B>文件夾
│ │
│ └2.php
└index.php
現在根目錄下的index.php要包含A文件夾內的1.php文件,則用include "./A/1.php"即可
而1文件夾內的1.php又包含了B文件夾內的2.php,則1.php內寫上include "../B/2.PHP"即可
可是要知道,當index.php包含了1.php之後,編譯是在index.php里進行的
也就是index.php所包含文件里的include都是相對於index.php的
那麼1.php被包含進index.php里了,那麼就要相對於index.php尋找2.php了
而上面說了,1.php里寫的是include "../B/2.php",現在編譯文件已經相對於網站根目錄了(即相對於index.php)
"../"則意味著還要再返回上一級目錄尋找,那麼怎麼會找得到。
在網上也尋找過一些方法,最好的辦法還是都採用絕對路徑方法較妥。
可以定義一個單入口文件,將要包含的文件包含進來
定義一個常量define("__ROOT__",dirname(__FILE__));,那麼在寫後面的文件過程中,只需要採用絕對方式,加上__ROOT__就行了。
require dirname(__FILE__) . '/library/Zend/Loader.php';
2022年8月8日 星期一
2021年9月15日 星期三
2021年8月14日 星期六
(node.js impoet)__filename, __dirname
import { dirname } from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename)