Git is a popular version control system that is used by developers to track changes made to their code. Branches are an important aspect of Git, as they allow developers to work on multiple features or bug fixes in parallel without affecting the main codebase. In Git, you can create two types of branches: local branches and remote branches. Local branches are branches that exist only on your local machine, whereas remote branches are branches that exist on a remote repository, such as Github, BitBucket, AWS CodeCommit, or Gitlab. Remote branches are useful when you want to collaborate with other…
Author: Rahul
Git is a popular distributed version control system that is widely used for software development and other collaborative projects. One of the key features of Git is its ability to work with remote repositories, allowing you to share code and collaborate with others on your projects. In this article, we will discuss how to list and checkout remote branches in Git. 1. Listing Remote Branches To list all of the remote branches in your Git repository, you can use the following command: git branch -r This command will display a list of all the remote branches that are currently available…
PHP, a versatile server-side scripting language, is a popular choice for web development due to its simplicity and extensive functionality. One of these essential functionalities is reading file content into strings, which can be achieved using the `file_get_contents()` function. This article will guide you through the understanding and usage of this significant PHP function. Understanding file_get_contents() The `file_get_contents()` function is a built-in PHP function used for reading data from a file, a URL, or an HTTP or FTP stream. When invoked, the function reads the entire file into a string. It is an effective method for file reading due to…
The fread() function is used to read from a file. It allows you to read from any stream or file, as long as it’s a binary stream. fread() reads the specified number of bytes into the given array, starting at the position in bytes. Let’s take a look at how the PHP fread() function works and see some examples of how to use it. Continue reading to learn more. How to use PHP fread() function? The fread() function is used to read from a file. It allows you to read from any stream or file, as long as it’s a…
PHP fgets() function is used for reading a single line from a file. This function takes two arguments as described below. 1. File specifies the filename to read content 2. Length Optional parameter specifies the number of bytes to read from the file. Syntax PHP fgets() function uses the following syntax. fgets(file, length) Example – Read a single line Below are two examples of a reading single line from a file. Use this example to read the complete first-line content from a file.
1 2 3 4 5 6 | <?php $fn = fopen("/var/data/myfile.txt","r"); $result = fgets($fn); echo $result; fclose($fn); ?> |
Instead of a line, you can also define the number of bytes to read from a…
PHP fwrite() function used to write data to file. This function take three arguments 1. File specifies filename to write 2. String specifies the string to write to file 3. Lenght specifies maximum number of bytes to write to file (optional) Syntax PHP fwrite() function uses following syntax fwrite(file, string, length) Example Below is the sample example of writing data to file using php script. In below example first line will open myfile.txt in edit mode in current directory. Second line will write string to file, you can also specify the lenght here and result the number of bytes written.…
Node.js fs.writeFile() method writes data to a file asynchronously with replacing the file in case of already exists. This function can write data from a string or a buffer. The encoding option is ignored if data is a buffer. It defaults encoding is ‘utf8’, Default file mode is 0666 and default flag is used ‘w’ means write mode. Syntax The fs.writeFile() function in Nodejs (JavaScript) uses the following syntax. fs.writeFile(filename, data[, options], callback) Here: filename is the filename with path. data is the String or buffer to write options can be an object which is like {encoding, mode, flag}. callback…
Python is a powerful programming language. It is very friendly and easy to learn. At the writing time of this article Python 3.5.9 is the latest stable version available to install. This tutorial will help you to install Python 3.5.9 on your CentOS, Red Hat & Fedora operating systems. Step 1 – Prerequisites Use the following command to install prerequisites for Python before installing it. yum install gcc sqlite-devel Step 2 – Download Python 3.5 Download Python using following command from python official site. You can also download latest version in place of specified below. cd /usr/src wget https://www.python.org/ftp/python/3.5.9/Python-3.5.9.tgz Now…
Go is an open-source programming language developed by a team at Google. It provides easy to build simple, reliable, and efficient software. This language is designed for writing servers, that’s why it is using widely these days. Go has released the latest version 1.25. This tutorial will help you to install Go 1.25 on your Ubuntu 25.10, 24.04 LTS and previous Ubuntu systems. Step 1: Install Go on Ubuntu Login to your Ubuntu system using ssh and upgrade to apply latest security updates there. sudo apt update sudo apt-get -y upgrade Now download the Go language binary archive file using…
This article will help you to install Python 3.5.9 on Ubuntu, Debian, and Linuxmint operating system. To know more about this version visit Python official website. Step 1 – Prerequisites You must have fulfilled all the prerequisites for installing Python on Ubuntu, Debian and Linuxmint. Use the following command to install all the prerequisites. After that go for the Python installation on Ubuntu. sudo apt-get install build-essential checkinstall sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev Step 2 – Download Python 3.5 Download Python source code archive from its official download website. You can also download Python…
