WebDAV (Web Distributed Authoring and Versioning) is an extension of the HTTP/1.1 protocol, which enables users to create, modify, and delete files on remote web servers. This protocol provides a standardized way for users to collaboratively edit and manage files on the web, much like a remote file system. WebDAV Features WebDAV introduces several features
Read more
Tag: PHP
Linux Kernel 4.19.70 Release
Posted onThis post summarizes new features, bugfixes and changes in Linux kernel release 4.19.70. Linux 4.19.70 Release contains 95 changes, patches or new features. In total, there are 101,521 lines of Linux source code changed/added in Linux 4.19.70 release compared to Linux 4.19 release. To view the source code of Linux 4.19.70 kernel release online, please
Read more
How to Count the Number of Words in a File in PHP?
Posted onCounting the number of words in a file is useful in many programs. In this post, we will discuss how to count the number of words in a file in a PHP script. In PHP standard library, we have function str_word_count($str) which returns the number of words from a string $str. On the other hand,
Read more
How to Convert Integers to Strings and Strings to Integers in PHP
Posted onConversion from integer to string and from string to integer are common operations in most applications such as C++. PHP has its uniqueness in language and standard library design. In this post, we will check methods to convert integers to strings and vice versa. Convert string to int in PHP You can cast a string
Read more
Call a Function by Its Name as a String in PHP
Posted onIn PHP, it is possible to call a function by its name as a string. This can be useful when the name of the function is not known until runtime, or when the name of the function is stored in a variable or retrieved from a database or other external source. To call a function
Read more
How to add PHP DOMDocument extension to httpd in CentOS 7?
Posted onJust migrated a PHP site to a new server. However, in /var/log/httpd/error_log, there are errors like [:error] [pid 2810] [client 61.92.242.24:43372] PHP Fatal error: Class ‘DOMDocument’ not found in /var/www/…/some.php on line 16 How to add PHP DOMDocument extension to httpd in CentOS 7? You need to install the package php-xml to have DOMCoument support
Read more
How to get a substring at words boundaries in PHP?
Posted onHow to get a substring at words boundaries in PHP? For example, for a string $a = “ab cc dde ffg ff”;, I would like to get its substring of length at most 7 from position 0 without breaking words. A simple substring($a, 0, 7) will break the word dde. Here, we consider “words” are
Read more
How to convert a piece of HTML code to plain text in PHP?
Posted onHow to convert a piece of HTML code to plain text without leading and ending spaces in PHP? For example, I would like to convert <div> <b>hello</b> world</div> to a string hello world You may use this piece of code in PHP to strip HTML tags, remove leading and ending spaces and convert special characters
Read more
How to get the full request URL in PHP?
Posted onHow to get the full request URL of the page being processed in PHP? If you are sure the request is a http or https one, and the PHP script is executed according to (e.g. by a load balancer or apache reverse proxy) the REQUEST_URI/HTTP_HOST which are set by the client, the PHP script can
Read more
How to disable PHP short open tags?
Posted onSome of my pages has XML tags like ‘<?xml ?>’ which are considered by PHP as short open tags ‘<? ?>’. How to disable PHP short open tags? In PHP, to disable the short open tags, you can set the variable short_open_tags = FALSE; in your php.ini. Reference: short_open_tags in php.ini
How to change the maximum uploading size for PHP with Apache on Linux?
Posted onHow to change the maximum uploading size for PHP with Apache on Linux? PHP has parameters to control the maximum uploading size. Here, we use Ubuntu 18.04 LTS default version as an example. First, open the php.ini configuration file using your favorite editor /etc/php/7.2/apache2/php.ini Then, find the following parts ; Maximum size of POST data
Read more
How to print a line to STDERR and STDOUT in PHP?
Posted onIn PHP, how to print a string as a line to STDOUT? That is, the string and the newline character, nicely? And similarly, how to print the line to STDERR? In PHP, you may print a line to STDOUT using echo by appending the PHP_EOL to the string: echo $your_msg . PHP_EOL; For example, $
Read more
How to split a string by string in PHP?
Posted onHow to split a string by string in PHP? For example, “a string separated by space” => [“a”, “string”, “separated”, “by”, “space”] and “a,string,separated,by,comma” => [“a”, “string”, “separated”, “by”, “comma”] The commonly used `explode()` is not enough here because multiple delimiters should be consider as one (such as ” “, 3 spaces together, is consider
Read more
How to get the epoch timestamp in PHP?
Posted onIn PHP, how to get the epoch timestamp, the number of seconds passed since the epoch? In PHP, you can use the time() function. ts = time(); To get the microsecond together too as a float number, use the microtime(true) function. ts2 = microtime(true); Example: $ php -a Interactive shell php > echo time() .
Read more
How to process a file line by line in PHP?
Posted onIn PHP, how to process a file line by line? The file is a plain text line like input.txt. As an example, the process can be to just print it out. In PHP, you can use this code snippet to process a file line by line: if ( ($fhandle = fopen(“./input.txt”, “r”) !== FALSE )
Read more
Any good Java REPL tool/implementation?
Posted onAny good suggestions on a Java REPL implementation like ‘scala’ and ‘python’ or ‘php -a’? The java-repl tool https://github.com/albertlatacz/java-repl/ works nicely for most situations for me. It is released as a .jar. Hence, it is easy to download and run: $ wget –quiet https://github.com/albertlatacz/java-repl/releases/download/428/javarepl-428.jar -O /tmp/javarepo-428.jar && java -jar /tmp/javarepo-428.jar One usage example is as
Read more
How to do a good research in system field?
Posted onWe may need to check some materials about how to do good research in system field if you a Ph.D. focusing on system research. Some references: 1, How to write a good systems paper 2, How to be a good graduate student 3, Doing a System Ph.D. 4, Giving an Academic Talk Welcome to add
Read more
Cannot start VM with error “no network with matching name ‘default'”
Posted onI update libvirt version and want to start VM with the new libvirt tools but I failed as follows. > sudo virsh start kvm1 error: Failed to start domain kvm1 error: Network not found: no network with matching name ‘default’ It seems that the default ‘virbr0’ is missing after I update libvirt so I solve
Read more
Why I got message “invalid syntax, continuing…” when I execute “sysctl”?
Posted onWhen I tried to apply new configuration in /etc/sysctl.conf, I got following message. warning: /etc/sysctl.conf(44): invalid syntax, continuing… Sounds like your changed /etc/sysctl.conf has problem. You may post the content of your /etc/sysctl.conf here to let other have a check. net.ipv4.ip_forward = 0 net.ipv4.conf.default.rp_filter = 1 net.ipv4.conf.default.accept_source_route = 0 kernel.sysrq = 0 kernel.core_uses_pid = 1
Read more
How to install glibc, glibc-common and GD libraries independently?
Posted onI already have PHP and nginx installed and running on my on centOS 6.7. Please guide me, how can install glibc, glibc-common and GD libraries independently on my centOS 6.7 without crashing my system? I am not sure how you installed PHP and nginx. If they are installed from CentOS6.7’s Yum repository, you may install
Read more