Friday, July 3, 2020

How to Embed an Image In HTML Page Using PHP

Sometimes, you might want to get a self-contaned HTML page that does not have to send a request to fetch an image from your server. This also can be helpful if you want to send HTML emails. To embed an image, first we have to read the image file and then encode it in base 64 and then add to to our HTML. The following code sample shows how to do it.
$file = 'path/to/my/file/image.jpg';
$rawData = file_get_contents($file);
$encoded = base64_encode($rawData);
echo '<img src="data:image/jpg;base64,'.$encoded.'" >';

Monday, June 29, 2020

How to Read a File In PHP

There are two ways to read whole content of a file in PHP language. First way is to use the function fread() with the function filesize(). The second way is to use the function file_get_content().

Examples

The following code shows how to use the first method.
$path = "C:\Users\XUser\documents\my-file.txt";
$stream = fopen($path, 'r');
$wholeContent = fread($stream, filesize($path));
fclose($stream);

The following code shows how to use the first method.
$path = "C:\Users\XUser\documents\my-file.txt";
$stream = file_get_content($path);

As for me, I recomend the second way over the first one. Because in some cases, I have seen that the first way does not read the whole file. In addition, it is easier to understand than the first one

Wednesday, June 24, 2020

How to Delete a Tag From GitHub Using GitHub Desktop

Very simple. All what you have to do is the following:
1- Open command line by opening the menu "Repository > Open in Command Prompt".
2- Execute the following command: "git push origin :<TAG_NAM>.
3- If it asks you to login, enter your credentials.
4- The tag will be removed and a message in the terminal that says the tag is removed will appear.

Saturday, October 19, 2019

Music That I Like Part 2 : Games, Boss Fight

We are back with another set of music. If you have missed part 1, click here. In this post, I have selected 3 music instruments from YouTube. The 3 are from well known video games. The songs are theme songs of final boss in the game. The first one is "Megaman X6", The second is "Undertale" and the last one is from "Crash Bandicoot 3"

Mega Man X6 OST - Sigma 2 - Final

One of my favorite games are Megaman X series. The first Megaman X game that I have ever played was Megaman X5. In general, The boss fight music in the game is Rock Music and I like rock music. Not just that, most of the game music tend to have a flavor of rock music. If you have ever played any X game before, you will recognize the music. It is a remix of Sigma theme from previous X games.

Undertale - Megalovania

The game is one of most well known games. It has a very mysterious story line which makes it fun to play. Even though the art of the looks like it was made in the 90s, it is actually new. The music in the video is played when you fight a caracter named "Sans". The music has a feeling of fun and horror in addition to rock which makes it very good. You might get board at the beginning because of the repeated milady. But continue listening till the end.

Crash Bandicoot [PRE-CONSOLE MUSIC] - Neo Cortex (CB3)

Neo Cortex is famous character that known for his evil plans in the game "Crash Bandicoot". But when it comes to his theme music in "Crash Bandicoot 3", it is an amazing piece of art. Another thing that I would like to mension is that this theme song is based on "Crash Bandicoot 1" is last boss fight which I can call it the most evil theme that I have ever heard. There is a new remix of the theme song which is used in the new game "Crash Bandicoot N. Sane Trilogy". You can listen to it here.