ALL
How to Understand and Use nil in Golang Correctly?
In Golang, nil is a predefined identifier that carries different meanings in various contexts, but typically represents "none", "empty" or "zero value". It can be assigned to variables of pointer, slice, map, channel, function, and interface types. Understanding the significance of nil is crucial for writing robust Go programs, as mishandling nil can lead to unexpected issues.nil in PointersIn Go, pointers are a fundamental type that stores the memory address of a variable. When a pointer is declared but not initialized, its value is nil. The following example code illustrates this:package mai...
Handy PHP functions should be in your toolkit
When developing projects, there are always some common work should be accomplished, for example, encrption/decryption, get IP. As a PHP developer, you should have a list of the handy functions in your toolkit so that you can pick up in every project you work on. Here is a summary of some handy PHP functions.1. PHP encryption/decryptionEncryption/decryption can be used when storing user confidential information such as passwords. Below function uses base64 and MD5 to accomplish encryption/decryption.function encryptDecrypt($key, $string, $decrypt){ if($decrypt){ $decrypted = rtrim(m...
5,104 0 PHP SQL INJECTION FUNCTION REAL IP
10 less known but useful PHP functions
PHP has abundant built in functions. As PHP developers, we may have used many of them. But there are still some useful functions we may not be so familiar with. In this post, we will introduce some of them.levenshtein()Have you ever wondered how to check differences between two works? This function just does what you want. It can tell you how much the difference is between two words.<?php$str1 = "carrot";$str2 = "carrrott";echo levenshtein($str1, $str2); //Outputs 2?>get_defined_vars()This is a very useful function when you wants to debug your codes when there are some issues. It will re...
Basic Patterns for Everyday Programming
For most of you the patterns mentioned below should be nothing new. These are very basic stuff we slap into our code everyday and at times feels they are actually code smells than smart patterns. However, I've been doing some code reviewing lately and came across many code that lacks even these basic traits. So I thought of writing them down as a help for novice developers who would want to get a better grasp at these.These patterns are commonly applicable in most general purpose programming languages, with slight syntactical changes. I use Ruby and JavaScript for the examples in this post.Ver...
4,663 0 JAVASCRIPT CODE PATTERN FUNCTION NULL ASSIGN DEFAULT VALUE