PHP 文件操作類(創(chuàng)建文件并寫入) 生成日記
Jun 13, 2016 am 11:58 AM
PHP 文件操作類(創(chuàng)建文件并寫入) 生成日志
<?php /** * 文件操作(生成日志)支持多條插入 * (如果插入多條語句并換行 用','逗號(hào)分開) * */class log { public $path = './info.txt'; //默認(rèn)值文件 public $mode = 'a'; //默認(rèn)追加寫 public $content = '默認(rèn)值:空'; //默認(rèn)內(nèi)容是 空 public function addlog($path = null, $mode = null, $content = null) { //判斷寫入的文件名是否為空 if (! empty ( $path )) { $this->path = $path; } //判斷操作方式 a追加寫 if (! empty ( $mode )) { $this->mode = $mode; } //判斷寫入的內(nèi)容 if (! empty ( $content )) { $this->content = $content; } $handle = fopen ( $this->path, $this->mode ); //拆分換行 $string = explode ( ",", $this->content ); foreach ( $string as $v ) { fwrite ( $handle, $v . "\r\n" ); } fclose ( $handle ); }}//使用$log = new log ();// $log->addlog (); //不傳值 走默認(rèn)值// $log->addlog ( "./log", "a", " 內(nèi)容1:$content1 內(nèi)容2: $content2 內(nèi)容3: $content3 " ); //傳多個(gè)內(nèi)容// $log->addlog ( "./log", "a", "123,123,123" ); //一次插入并換行

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Use the math.Log2 function to calculate the base 2 logarithm of a specified number. In mathematics, the logarithm is an important concept that describes the exponential relationship of one number to another number (the so-called base). Among them, the base 2 logarithm is particularly common and is frequently used in the fields of computer science and information technology. In the Python programming language, we can calculate the base 2 logarithm of a number using the log2 function from the math library. Here is a simple code example: importmathdef

php提交表單通過后,彈出的對(duì)話框怎樣在當(dāng)前頁彈出php提交表單通過后,彈出的對(duì)話框怎樣在當(dāng)前頁彈出而不是在空白頁彈出?想實(shí)現(xiàn)這樣的效果:而不是空白頁彈出:------解決方案--------------------如果你的驗(yàn)證用PHP在后端,那么就用Ajax;僅供參考:HTML code

This article will help you interpret the vue source code and introduce why you can use this to access properties in various options in Vue2. I hope it will be helpful to everyone!

A colleague got stuck due to a bug pointed by this. Vue2’s this pointing problem caused an arrow function to be used, resulting in the inability to get the corresponding props. He didn't know it when I introduced it to him, and then I deliberately looked at the front-end communication group. So far, at least 70% of front-end programmers still don't understand it. Today I will share with you this link. If everything is wrong If you haven’t learned it yet, please give me a big mouth.

Use the math.Log10 function to calculate the base 10 logarithm of a specified number. Logarithms are a common concept in mathematics and computer science. We often use logarithms to describe the size or proportion of numbers. In computer programming, the commonly used logarithmic function is the logarithmic function with base 10. In the Python language, you can use the log10 function in the math library to calculate the base 10 logarithm of a specified number. Below we will demonstrate the use of this function through a simple code example. First, we need

Flexible use of this keyword in jQuery In jQuery, the this keyword is a very important and flexible concept. It is used to refer to the DOM element currently being manipulated. By rationally using this keyword, we can easily operate elements on the page and achieve various interactive effects and functions. This article will combine specific code examples to introduce the flexible use of this keyword in jQuery. Simple this example First, let's look at a simple this example. Suppose we have a

What is this? The following article will introduce you to this in JavaScript, and talk about the differences between this in different calling methods of functions. I hope it will be helpful to you!

How does JavaScript change this pointer? The following article will introduce to you three methods of changing this pointer in JS. I hope it will be helpful to you!
