本文目錄一覽:
- 1、PHP代碼為什麼提示有錯?
- 2、php設置成utf-8還是亂碼了怎麼辦
- 3、用php編寫代碼時,數據庫設計時,一個字段的數據類型為varchar(5)可是當我輸入一個中文字“里”時報錯。
- 4、PHP代碼問題,總是報錯,求指教
- 5、php報錯,怎麼辦?(具體內容在下面)
- 6、Sublime Text,php代碼格式化插件codeformatter 設置PHP代碼格式時報錯 怎麼處理
PHP代碼為什麼提示有錯?
你好, 你可以這樣試下.(首先先說下我認為什麼會報錯: 因為 $in 是未定義的,所以會報錯;還有當你改變成 $_POST[‘in’] 為什麼還會報錯呢,因為 $_POST[‘in’] 也是還未存在的,為什麼呢?因為你還沒有提交數據,雖然表單和接收表單值的處理程序在同一個頁面,可是因為你在一開始打開頁面時,你是還沒有提交數據的,所以 $_POST 數組中就不存在 $_POST[‘in’],只有當你提交了數據之後, $_POST[‘in’] 才存在的)
我覺得這樣做可以解決: 因為 $_POST[‘in’] 在一開始是不存在的,所以你可以先判斷下,然後再接收數據。
你 標註箭頭的那一行可以這樣寫: $input=isset($_POST[‘in’])?$_POST[‘in’]:”; 這個寫法你應該可以理解吧. 也就是說, 利用 isset() 先判斷 $_POST[‘in’] 存不存在,如果存在,就 把 $_POST[‘in’] 的值賦給 $input ,如果不存在,就賦空值給 $input ; 這樣就不會報錯了;
當你提交數據時, $input 就能接收你輸入的值了。
希望能幫到你,謝謝!
php設置成utf-8還是亂碼了怎麼辦
有時後php代碼裡邊設置了“header(“Content-type:
text/html;
charset=utf-8″);”不一定會管用,因為有時文件本身格式就是錯誤的,你先把代碼複製到一個txt文件裡邊,然後用代碼工具對php文件進行轉碼成utf-8格式(這時你就會發現裡邊的代碼亂碼了,由其是中文和特殊字符),再把txt裡邊的代碼複製覆蓋原來的php文件內容,然後保存即可,例如用Notepad++
工具
可以對文件本身進行轉碼
用php編寫代碼時,數據庫設計時,一個字段的數據類型為varchar(5)可是當我輸入一個中文字“里”時報錯。
編碼問題啊,把編碼設置成utf8_general_ci就行了,你的不用看就知道你編碼不對,設置完了,重新把值存下就行了
PHP代碼問題,總是報錯,求指教
1);/script”; }
if($row[num]1){
echo “script language=javascriptalert(‘該優惠券庫存不足,領取失敗!’);window.history.go(-1);/script”; }
仔細看} }和 {{, 看出來了吧 ,你用全角打的{是不行的 ,會報錯的
php要用半角的打,{}這才對 ,把上述代碼全角的{}改成半角的{}即可
php報錯,怎麼辦?(具體內容在下面)
定義和用法:error_reporting() 設置 PHP 的報錯級別並返回當前級別。函數語法:error_reporting(report_level)如果參數 level 未指定,當前報錯級別將被返回。下面幾項是 level 可能的值:值 常量 描述1 E_ERROR 致命的運行錯誤。錯誤無法恢復,暫停執行腳本。2 E_WARNING 運行時警告(非致命性錯誤)。非致命的運行錯誤,腳本執行不會停止。4 E_PARSE 編譯時解析錯誤。解析錯誤只由分析器產生。8 E_NOTICE 運行時提醒(這些經常是你代碼中的bug引起的,也可能是有意的行為造成的。)16 E_CORE_ERROR PHP啟動時初始化過程中的致命錯誤。32 E_CORE_WARNING PHP啟動時初始化過程中的警告(非致命性錯)。64 E_COMPILE_ERROR 編譯時致命性錯。這就像由Zend腳本引擎生成了一個E_ERROR。128 E_COMPILE_WARNING 編譯時警告(非致命性錯)。這就像由Zend腳本引擎生成了一個E_WARNING警告。256 E_USER_ERROR 用戶自定義的錯誤消息。這就像由使用PHP函數trigger_error(程序員設置E_ERROR)512 E_USER_WARNING 用戶自定義的警告消息。這就像由使用PHP函數trigger_error(程序員設定的一個E_WARNING警告)1024 E_USER_NOTICE 用戶自定義的提醒消息。這就像一個由使用PHP函數trigger_error(程序員一個E_NOTICE集)4096 E_RECOVERABLE_ERROR 開捕致命錯誤。這就像一個E_ERROR,但可以通過用戶定義的處理捕獲(又見set_error_handler())8191 E_ALL 所有的錯誤和警告(不包括 E_STRICT) (E_STRICT will be part of E_ALL as of PHP 6.0)例子:任意數目的以上選項都可以用“或”來連接(用 OR 或 |),這樣可以報告所有需要的各級別錯誤。
Sublime Text,php代碼格式化插件codeformatter 設置PHP代碼格式時報錯 怎麼處理
{
“codeformatter_debug”: false,
“codeformatter_php_options”:
{
“syntaxes”: “php”, // Syntax names which must process PHP formatter
“php_path”: “這裡改成你php的路徑”, // Path for PHP executable, e.g. “/usr/lib/php” or “C:/Program Files/PHP/php.exe”. If empty, uses command “php” from system environments
“format_on_save”: false, // Format on save. Either a boolean (true/false) or a string regexp tested on filename. Example : “^((?!.min.|vendor).)*$”
“php55_compat”: false, // PHP 5.5 compatible mode
“psr1”: false, // Activate PSR1 style
“psr1_naming”: false, // Activate PSR1 style – Section 3 and 4.3 – Class and method names case
“psr2”: true, // Activate PSR2 style
“indent_with_space”: 4, // Use spaces instead of tabs for indentation
“enable_auto_align”: true, // Enable auto align of = and =
“visibility_order”: true, // Fixes visibility order for method in classes – PSR-2 4.2
“smart_linebreak_after_curly”: true, // Convert multistatement blocks into multiline blocks
// Enable specific transformations. Example: [“ConvertOpenTagWithEcho”, “PrettyPrintDocBlocks”]
// You can list all available transformations from command palette: CodeFormatter: Show PHP Transformations
“passes”: [],
// Disable specific transformations
“excludes”: []
},
“codeformatter_js_options”:
{
“syntaxes”: “javascript,json”, // Syntax names which must process JS formatter
“format_on_save”: false, // Format on save. Either a boolean (true/false) or a string regexp tested on filename. Example : “^((?!.min.|vendor).)*$”
“indent_size”: 4, // indentation size
“indent_char”: ” “, // Indent character
“indent_with_tabs”: false, // Indent with one tab (overrides indent_size and indent_char options)
“eol”: “\n”, // EOL symbol
“preserve_newlines”: false, // whether existing line breaks should be preserved,
“max_preserve_newlines”: 10, // maximum number of line breaks to be preserved in one chunk
“space_in_paren”: false, // Add padding spaces within paren, ie. f( a, b )
“space_in_empty_paren”: false, // Add padding spaces within paren if parent empty, ie. f( )
“e4x”: false, // Pass E4X xml literals through untouched
“jslint_happy”: false, // if true, then jslint-stricter mode is enforced. Example function () vs function()
“space_after_anon_function”: false, // Space after anonimouse functions
“brace_style”: “collapse”, // “collapse” | “expand” | “end-expand”. put braces on the same line as control statements (default), or put braces on own line (Allman / ANSI style), or just put end braces on own line.
“keep_array_indentation”: false, // keep array indentation.
“keep_function_indentation”: false, // keep function indentation.
“eval_code”: false, // eval code
“unescape_strings”: false, // Decode printable characters encoded in xNN notation
“wrap_line_length”: 0, // Wrap lines at next opportunity after N characters
“unindent_chained_methods”: false, // Unindent chained method calls
“break_chained_methods”: false, // Break chained method calls across subsequent lines
“end_with_newline”: false, // Add new line at end of file
“comma_first”: false, // Add comma first
“operator_position”: “before-newline” // Operator position: before-newline, after-newline, preserve-newline
},
“codeformatter_css_options”:
{
“syntaxes”: “css,less”, // Syntax names which must process CSS formatter
“format_on_save”: false, // Format on save. Either a boolean (true/false) or a string regexp tested on filename. Example : “^((?!.min.|vendor).)*$”
“indent_size”: 4, // Indentation size
“indent_char”: ” “, // Indentation character
“indent_with_tabs”: false, // Indent with one tab (overrides indent_size and indent_char options)
“selector_separator_newline”: false, // Add new lines after selector separators
“end_with_newline”: false, // Add new line of end in file
“newline_between_rules”: false, // Add new line between rules
“space_around_combinator”: false, // Space around combinator
“eol”: “\n” // EOL symbol
},
“codeformatter_scss_options”:
{
“syntaxes”: “scss,sass”, // Indentation size
“format_on_save”: false, // Format on save. Either a boolean (true/false) or a string regexp tested on filename. Example : “^((?!.min.|vendor).)*$”
“indent_size”: 4, // Indentation size
“indent_char”: ” “, // Indentation character
“indent_with_tabs”: false, // Indent with one tab (overrides indent_size and indent_char options)
“selector_separator_newline”: false, // Add new lines after selector separators
“end_with_newline”: false, // Add new line of end in file
“newline_between_rules”: false, // Add new line between rules
“space_around_combinator”: false, // Space around combinator
“eol”: “\n” // EOL symbol
},
“codeformatter_html_options”:
{
“syntaxes”: “html,blade,asp,xml”, // Syntax names which must process HTML formatter
“format_on_save”: false, // Format on save. Either a boolean (true/false) or a string regexp tested on filename. Example : “^((?!.min.|vendor).)*$”
“formatter_version”: “bs4”, // Which formatter to use. Current options are “bs4” and “regexp”. If an error occurs while loading the bs4 formatter, the regexp formatter will automatically be used
“indent_size”: 4, // indentation size
“indent_char”: ” “, // Indentation character
“indent_with_tabs”: false, // Indent with one tab (overrides indent_size and indent_char options)
“exception_on_tag_mismatch”: false, // If the last closing tag is not at the same indentation level as the first opening tag, there’s probably a tag mismatch in the file
“expand_javascript”: false, // (Under construction) Expand JavaScript inside of script tags (also affects CSS purely by coincidence)
“expand_tags”: false, // Expand tag attributes onto new lines
“minimum_attribute_count”: 2, // Minimum number of attributes needed before tag attributes are expanded to new lines
“first_attribute_on_new_line”: false, // Put all attributes on separate lines from the tag (only uses 1 indentation unit as opposed to lining all attributes up with the first)
“reduce_empty_tags”: false, // Put closing tags on same line as opening tag if there is no content between them
“reduce_whole_word_tags”: false, // Put closing tags on same line as opening tag if there is whole word between them
“custom_singletons”: “” // Custom singleton tags for various template languages outside of the HTML5 spec
},
“codeformatter_python_options”:
{
“syntaxes”: “python”, // Syntax names which must process Python formatter
“format_on_save”: false, // Format on save. Either a boolean (true/false) or a string regexp tested on filename. Example : “^((?!.min.|vendor).)*$”
“indent_size”: 1, // indentation size
“indent_with_tabs”: true, // Indent with tabs or spaces
“max_char”: 80, // Width of output lines in characters.
“assignment”: ” = “, // This is how the assignment operator is to appear.
“function_param_assignment”: “=”, // This is how function-parameter assignment should appear.
“function_param_sep”: “, “, // This is how function parameters are separated.
“list_sep”: “, “, // This is how list items are separated.
“subscript_sep”: “=”, // This is how subscripts are separated.
“dict_colon”: “: “, // This separates dictionary keys from values.
“slice_colon”: “:”, // this separates the start:end indices of slices.
“comment_prefix”: “# “, // This is the sentinel that marks the beginning of a commentary string.
“shebang”: “#!/usr/bin/env python”, // Hashbang, a line-one comment naming the Python interpreter to Unix shells.
“boilerplate”: “”, // Standard code block (if any). This is inserted after the module doc string on output.
“blank_line”: “”, // This is how a blank line is to appear (up to the newline character).
“keep_blank_lines”: true, // If true, preserve one blank where blank(s) are encountered.
“add_blank_lines_around_comments”: true, // If true, set off comment blocks with blanks.
“add_blank_line_after_doc_string”: true, // If true, add blank line after doc strings.
“max_seps_func_def”: 3, // Split lines containing longer function definitions.
“max_seps_func_ref”: 5, // Split lines containing longer function calls.
“max_seps_series”: 5, // Split lines containing longer lists or tuples.
“max_seps_dict”: 3, // Split lines containing longer dictionary definitions.
“max_lines_before_split_lit”: 2, // Split string literals containing more newline characters.
“left_margin”: “”, // This is how the left margin is to appear.
“normalize_doc_strings”: false, // If true, normalize white space in doc strings.
“leftjust_doc_strings”: false, // If true, left justify doc strings.
“wrap_doc_strings”: false, // If true, wrap doc strings to max_char.
“leftjust_comments”: false, // If true, left justify comments.
“wrap_comments”: false, // If true, wrap comments to max_char.
“double_quoted_strings”: false, // If true, use quotes instead of apostrophes for string literals.
“single_quoted_strings”: false, // If true, use apostrophes instead of quotes for string literals.
“can_split_strings”: false, // If true, longer strings are split at the max_char.
“doc_tab_replacement”: “….”, // This literal replaces tab characters in doc strings and comments.
// Optionally preserve unassigned constants so that code to be tidied
// may contain blocks of commented-out lines that have been no-op’ed
// with leading and trailing triple quotes. Python scripts may declare
// constants without assigning them to a variables, but CodeFormatter
// considers this wasteful and normally elides them.
“keep_unassigned_constants”: false,
// Optionally omit parentheses around tuples, which are superfluous
// after all. Normal CodeFormatter behavior will be still to include them
// as a sort of tuple display analogous to list displays, dict
// displays, and yet-to-come set displays.
“parenthesize_tuple_display”: true,
// When CodeFormatter splits longer lines because max_seps
// are exceeded, the statement normally is closed before the margin is
// restored. The closing bracket, brace, or parenthesis is placed at the
// current indent level. This looks ugly to “C” programmers. When
// java_style_list_dedent is True, the closing bracket, brace, or
// parenthesis is brought back left to the indent level of the enclosing
// statement.
“java_style_list_dedent”: false
},
“codeformatter_vbscript_options”:
{
“syntaxes”: “vbscript”, // Syntax names which must process VBScript formatter
“format_on_save”: false, // Format on save. Either a boolean (true/false) or a string regexp tested on filename. Example : “^((?!.min.|vendor).)*$”
“indent_size”: 1, // indentation size
“indent_char”: “\t”, // Indentation character
“indent_with_tabs”: true, // Indent with one tab (overrides indent_size and indent_char options)
“preserve_newlines”: true, // Preserve existing line-breaks
“max_preserve_newlines”: 10, // Maximum number of line-breaks to be preserved in one chunk
“opening_tags”: “^(Function .*|Sub .*|If .* Then|For .*|Do While .*|Select Case.*)”, // List of keywords which open a new block
“middle_tags”: “^(Else|ElseIf .* Then|Case .*)$”, // List of keywords which divide a block, but neither open or close the block
“closing_tags”: “(End Function|End Sub|End If|Next|Loop|End Select)$” // List of keywords which close an open block
},
“codeformatter_coldfusion_options”:
{
“syntaxes”: “coldfusion,cfm,cfml”, // Syntax names which must process Coldfusion Markup Language formatter
“format_on_save”: false, // Format on save. Either a boolean (true/false) or a string regexp tested on filename. Example : “^((?!.min.|vendor).)*$”
“indent_size”: 2, // indentation size
“indent_char”: ” “, // Indentation character
“indent_with_tabs”: false, // Indent with one tab (overrides indent_size and indent_char options)
“exception_on_tag_mismatch”: false, // If the last closing tag is not at the same indentation level as the first opening tag, there’s probably a tag mismatch in the file
“expand_javascript”: false, // (Under construction) Expand JavaScript inside of script tags (also affects CSS purely by coincidence)
“expand_tags”: false, // Expand tag attributes onto new lines
“minimum_attribute_count”: 2, // Minimum number of attributes needed before tag attributes are expanded to new lines
“first_attribute_on_new_line”: false, // Put all attributes on separate lines from the tag (only uses 1 indentation unit as opposed to lining all attributes up with the first)
“reduce_empty_tags”: false, // Put closing tags on same line as opening tag if there is no content between them
“reduce_whole_word_tags”: false, // Put closing tags on same line as opening tag if there is whole word between them
“custom_singletons”: “” // Custom singleton tags for various template languages outside of the HTML5 spec
}
}
原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-hant/n/287469.html