Posts

Showing posts from October, 2024

Exceptions in java ( AI article)

In Java, exceptions are events that disrupt the normal flow of a program's execution. They are used to handle errors and other exceptional events in a controlled manner. When an exception occurs, Java creates an exception object and "throws" it. The exception can then be "caught" and processed using special code blocks. Key Concepts of Exceptions in Java: 1. Types of Exceptions: Checked Exceptions: These are exceptions that are checked at compile-time. The programmer must handle these exceptions using a try-catch block or declare them using the throws keyword. Example: IOException, SQLException. Unchecked Exceptions: These exceptions are not checked at compile-time and occur due to programming errors. They extend RuntimeException and do not need to be explicitly handled. Example: NullPointerException, ArrayIndexOutOfBoundsException. Errors: These are serious problems, usually related to system resources, and should not be handled by normal exception-handling cod...

Update default username for wsl

open the file : /etc/wsl.conf add the lines after updating the username: -------------------------------------------- [user] default=username --------------------------------------------- Reference: https://superuser.com/questions/1566022/how-to-set-default-user-for-manually-installed-wsl-distro

Deprecated: strip_tags(): Passing null to parameter #1 ($string) of type string is deprecated ( AI generated)

 The error message you're seeing indicates that a null value is being passed to the strip_tags() function in PHP, which expects a string. Starting from PHP 8.1, passing null to functions that expect a string parameter is deprecated, and this will likely become an error in future PHP versions. To fix this issue, ensure that the value passed to strip_tags() is always a string. You can use a check to provide a default value if the variable is null . Here’s how you can modify your code to avoid the warning: php Copy code // Before: echo strip_tags ( $your_variable ); // After: ensure $your_variable is not null echo strip_tags ( $your_variable ?? '' ); This ensures that if $your_variable is null , an empty string ( '' ) is passed instead. Let me know if you need more help with this! ( Content provided with the assistance of ChatGPT, an AI model by OpenAI ) ref: https://stackoverflow.com/a/72628990/9005703