Showing posts with label variables. Show all posts
Showing posts with label variables. Show all posts

Sunday, September 29, 2024

Understanding PHP Data Types, A Practical Guide

Even though we have already installed and prepared everything we need to learn and program a programming language, as we prepared to learn the PHP programming language in the previous PHP tutorial post, see here; and since we have printed the famous "Hello World" on the local server web page; the first steps in programming begin with variables. Variables in programming are places in computer memory where data is stored that the program uses for calculation, processing, and manipulation. In the PHP programming language, as in other programming languages; variables are names used to reference places in memory. The easiest way to understand variables is to think of them as memory boxes. But not all boxes are the same. In some, you can put a value that represents an integer, while in others you can put floating-point numbers. There are also boxes in which you can put a set of any characters. To know what value, you can put in a variable, you need to know what data type you have decided to assign to a variable. All programming languages have variables and certain data types.

Most basic variable types are essentially the same or similar. However, some programming languages have more data types while others have fewer. Also, even the same name of a variable type in many programming languages can have different limitations. For example, in the PHP programming language, the float data type has the precision of the double data type, which means that the value of floating-point numbers is much larger than it would be if the data type was float in the C# programming language. Or instead of the char data type in C#, the string type is used in the PHP programming language, while char is a function used to convert an ASCII number to a character. So that you are not confused at the very beginning of learning data types, it is best to concentrate on the data types that the PHP programming language has.

The boss explains the importance of data types in PHP to a new employee

The boss explains the importance of data types in PHP to a new employee

Variables are the fundamental building blocks of every program. They serve as containers for data that can be changed and manipulated throughout the program's execution. In PHP, variables are declared simply by assigning a value to a name. The data type of a variable is determined automatically based on the assigned value. Variable names can include letters, numbers, and underscores, but they must start with a letter or an underscore. Additionally, PHP requires a dollar sign ($) before each variable name to identify it. For example, in this line, we've created a variable named $number and assigned the integer value 10 to it.

$number = 10;

It's essential to choose clear and descriptive variable names to enhance code readability. For instance, if a variable holds the value of the 13th salary, a suitable name would be $thirteenthSalary. Remember that PHP is case-sensitive, meaning $number and $Number are considered different variables. A common convention in PHP is to use camelCase for variable names, as seen in $thirteenthSalary.
Unlike many other programming languages, PHP doesn't require explicit type declarations. When you assign a value to a variable, its data type is inferred automatically, and the necessary memory is allocated.

Basic Data Types in PHP: Simply Explained

Monday, April 01, 2024

Master the Fundamentals of C# 12 Programming, How to use Variables, Data Types, and Constants in Your Projects?

In the previous lesson, we created our first C# 12 program. We learned how to print text to the Terminal panel and explored the three types of comments used in the C# programming language. Additionally, we discovered how to set attributes in the *.csproj file, which affects the entire project. We also delved into creating regions, which allow us to organize code into blocks and navigate through it easily, regardless of the number of lines of code.

Furthermore, despite the convenience of C# 12’s top-level statements, we can still create programs with the traditional Main method that you might recognize from older versions of the C# programming language. However, everything we’ve learned so far would only suffice for printing text on consoles. Programming encompasses much more than that! Let’s first focus on what programming is and what it involves.

A boy is learning C# 12 programming at home

A boy is learning C# 12 programming at home to make a game

Programming is the process of creating computer programs, where programmers use a specific language and tools to communicate with the computer. Programming is the art of writing code that enables computers to perform specific tasks and Programmers use various languages (such as C#, Python, Java, etc.) to write instructions for the computer. In any case, programming requires creativity and problem-solving skills. It goes beyond mere code writing. It involves creating solutions, thinking about problems, and communicating with computers to achieve desired functionality.

Programmers often need to devise innovative ways to tackle challenges. But how do computers actually function? Programming involves giving instructions to the computer in the form of one or more grouped lines of code, known as statements. These statements are grouped into methods, and methods into classes, to avoid code repetition in a project and enable calling previously written and tested code from other parts of the project. 

The code you write must have a purpose and be written with a significant reason. It should also be correct and optimized. Your computer will always execute exactly what you've instructed, regardless of whether it's logical. Logic and proper code writing are up to you. Learning programming usually begins with console applications. Although console applications aren’t used for creating market-ready 
programs due to their purely textual user interface, they are excellent for testing methods and classes.

Understanding Declarations, Variables, Data Types, and the Role of Constants

Wednesday, September 06, 2017

Šta je novo u C# programskom jeziku u verziji 7.0

Pre nego što i počnete da čitate ovaj post imajte u vidu da je on do sada jedan od najvećih postova na ovom blogu i da nije dovoljno ga samo jednom pogledati iako objašnjava samo suštinske promene koje nosi C# programerski jezik u verziji 7.0 . Takođe imajte u vidu da sam uložio izuzetno mnogo truda i vremena kako bi vam na najjednostavniji mogući način objasnio šta vas čeka novo u C# 7.0 kodiranju. Ali ove se promene ne mogu savladati odjednom već se sve uči korak po korak. Svaki dan po malo. Ovom prilikom se takođe zahvaljujem svima na porukama, podršci na društvenim mrežama i mom programerskom YouTube kanalu. Trenutno najnovija verzija C# programskog jezika 7.0 sa sobom donosi mnogo promena koje će vam definitivno omogućiti bolje i brže kodiranje. Microsoft Visual Studio2017 sa sobom nosi izuzetno moćne alate sa kojima će vaši programi u C# programskom jeziku i projekti definitivno biti sve više funkcionalni u sve većim i kompleksnijim poslovnim zahtevima.


( Microsoft konferencija, šta je novo u C# 7.0 )

Poznavanje programskog jezika C# u verziji 7.0 definitivno ima svoje prednosti. C# programski jezik i pored toga što se ne kotira visoko na listi programskih jezika; polako ali sigurno preuzima vodstvo na najkomplikovanijim poslovnim rešenjima. C# programski jezik koristi preko 2 miliona programera u celom svetu, sve se više koristi na univerzitetima i definitivno nije mrtav programski jezik. I ja sam čak razmišljao da pređem na PHP programski jezik, ali kad pogledam koliko truda i šta se sve poboljšalo u zadnje vreme u C# programskom jeziku, što bi rekli kod nas koliko je taj jezik uzeo maha; jednostavno ostajem i dalje privržen Microsoft tehnologijama koji mi omogućavaju da programiram na bilo kojoj platformi. Većini početnika se danas može izgubiti u C#  programskom jeziku i umesto da na ovaj programski jezik gledaju kao na najbolji i najlakši programskog jezik, oni kolutaju očima kad vide par linija code-a u programu. To je zbog nestrpljenja i želje da se odmah sve zna. Pogledajte sadržaj na mom blogu i krenite da programirate jedan po jedan program. Ne možete sve odjednom, ni ovaj post a tek blog nije napravljen odjednom. Budite disciplinovani i programirajte svaki dan makar pola sata, ali svaki dan. To je najbolji metod za učenje jer se C#  programski jezik zbog sve većeg progresa i primene u svemu je robustan i lako se zaboravlja kad se ne koristi. Otkucajte code isti kao u mojim primerima, zatim izmislite neki mali svoj vlastiti sličan primer i njega programirajte jer se najbolje pamti kad kodirate nešto iz vaše glave. Pogledajte sada šta je sve novo u C#  programskom jeziku u verziji 7.0.             

Literal digitalni separator i binarni literali