Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Server Side Programming Articles
Page 997 of 2109
How to add a new column to an existing table of Laravel in a migration?
Laravel migrations provide a convenient way to modify your database schema over time. The make:migration Artisan command enables you to add new columns to existing tables without affecting existing data. Creating an Initial Table First, let's create a basic table using the migration command. The syntax for creating a new table is ? php artisan make:migration create_students_table This generates a migration file in the database/migrations directory ?
Read MoreHow to access images inside a public folder in Laravel?
If you have an image stored in the public folder of Laravel, you can access or display it in the browser using various methods. In this article, we will learn some of these methods. Assume we have the image of a flower (flower.jpg) stored in the public/images folder as shown below ? Laravel Project Structure public/ images/ flower.jpg Now let us use the image to view inside the browser. Using url() Method The ...
Read MoreWhy do we assume strncpy insecure in C/C++?
The strncpy() function is used to copy a specified number of characters from a source string to a destination string. While it might seem safer than strcpy() because it limits the number of characters copied, strncpy() has several security vulnerabilities that make it unsafe for general use. Syntax char *strncpy(char *destination, const char *source, size_t n); Parameters: destination: Pointer to the destination array where content is to be copied source: Pointer to the source string to be copied n: Maximum number of characters to be copied from source Why strncpy() is Insecure ...
Read MoreAccessing array out of bounds in C/C++
An array in C is a fixed-size sequential collection of elements of the same data type where all elements are stored in contiguous memory. When an array is accessed out of bounds, undefined behavior occurs in C, unlike higher-level languages that throw exceptions. Syntax type arrayName[size]; // Valid indices: 0 to (size-1) // Out of bounds: index < 0 or index >= size Accessing Out of Bounds Memory Accessing out-of-bounds memory means trying to access an array index outside its valid range (index < 0 or index >= array size). This returns garbage values ...
Read MoreHow to get the server IP with Laravel?
In Laravel, you can get the server IP address using the global $_SERVER['SERVER_ADDR'] variable or Laravel's built−in request methods. The server IP represents the IP address of the server hosting your application. The $_SERVER superglobal variable contains information about headers, paths, and script locations, including server details. Using $_SERVER['SERVER_ADDR'] The simplest method is to access the server IP directly from the $_SERVER superglobal ? 127.0.0.1 Using Laravel's Request Object Laravel provides the request() helper function with a server() method to access server variables ? ...
Read MoreHow to write long strings in Multi-lines C/C++?
To write long strings in multi-lines, you can use the 'newline character' or 'string concatenation'. It increases the readability of the code, makes the code look clean, and you can avoid horizontal scrolling. In this article, we have a long string and our task is to write the long string in multi-lines in C. Syntax // Using newline character char str[] = "First lineSecond lineThird line"; // Using string concatenation char str[] = "First part of string " "Second part of string ...
Read MoreHow to check if a Laravel collection is empty?
Before checking if a Laravel collection is empty, let's understand what collections are in Laravel. Collection in Laravel is an API wrapper that helps you deal with different operations on arrays. It uses the class Illuminate\Support\Collection to handle arrays in Laravel. To create a collection from an array, use the collect() helper method that returns a collection instance. You can then chain methods like converting to lowercase and sorting on the collection. Installation: Make sure you have Laravel installed and create a controller using: php artisan make:controller UserController Using the isEmpty() Method The isEmpty() ...
Read MoreData Types we cannot use to create array in C
In C programming, arrays can be created using most data types like int, char, float, double, etc. However, there are certain data types that cannot be used to create arrays. The most notable restriction is with the void data type. Syntax datatype array_name[size]; // Valid for most data types void array_name[size]; // Invalid - compilation error Data Types That Cannot Be Used for Arrays 1. Void Data Type The void data type represents "no type" and has no size. Since arrays need to know the size of ...
Read MoreHow to pass a 2D array as a parameter in C?
In C programming, a 2D array can be passed as a parameter to a function in several ways. The method depends on whether the array dimensions are known at compile time or need to be determined at runtime. Syntax // Method 1: Fixed dimensions (known at compile time) void function_name(int arr[ROWS][COLS]); // Method 2: Variable dimensions (C99 and later) void function_name(int rows, int cols, int arr[rows][cols]); // Method 3: Using pointer to array void function_name(int (*arr)[COLS]); Method 1: Using Fixed Dimensions When array dimensions are known at compile time, you can specify ...
Read MoreWhen do function-level static variables get initialized in C/C++?
Static variables can be defined using the static keyword. They are variables that remain in memory while the program is running, meaning their lifetime is the entire program execution. This is different from automatic variables, which remain in memory only when their function is running and are destroyed when the function exits. Function-level static variables are initialized only once − the first time the function is called. The memory for them is allocated at program load time, but the initialization occurs during the first function execution. Syntax static data_type variable_name = initial_value; Example: Static ...
Read More