So I would like to enhance my ability in web technologies from html/css to javascript and php. I have two questrions:

What is the role of PHP in a website? Is it just used to hide code (e.g if a user inspects a webpage they cannot see the html) and transfer data (e.g. Save user data if they fill in a form)
Can PHP do anything javascript/html/css can do?
I appreciate any replies. I have a CS Degree but I seem to have graduated into an overwhelming world of different languages and really niche/new technology so I am rather overwhelmed when it comes to what technology to utilise when it comes to projects I want to build.

Thank you for taking the time to read this 🙂
Hey there, welcome to PHP.
PHP is a server-side language, which means the code gets run on a server, rather than in the browser, which is the case with HTML/CSS and JavaScript.

PHP can do many things. It can communicate with the database, save files on the filesystem, send emails, authenticate and authorize users to do certain things, render HTML and much more.
It does not hide any HTML. HTML is executed in the browser and there is no way for you to hide it (nor a reason). Instead, PHP can send the browser different HTML depending on a situation.

For example, if you are showing a greeting on your page, e.g. “Hello [user’s name]”, you can use PHP to get the user’s information and show the right name, and the browser will only see “Hello Brian” or “Hello Maria” etc.
PHP is primarily used to add dynamic functionality to websites or to power APIs.

This (and many others) is correct. For what I hope are obvious reasons, you would never want a client browser to connect directly to things like a database. Instead, you need a server to process requests, sanitize, and talk to other servers/services on the client’s behalf. This is a role PHP fills nicely. PHP != JavaScript/HTML/CSS. PHP can print out text in response to requests, and that text could be markup (like HTML), CSS, or JavaScript.
Welcome to the wide world of PHP!

Here’s a quick rundown:
PHP runs PHP code on the server. Javascript runs JavaScript on the client (browser).
When you run code on the server, you can access other things like databases.
Php renders html and makes it dynamic so information can change on the screen.

Php can be used to make rest APIs. The important thing to know is PHP is server side, JavaScript is client side.
As far as “hiding html”, that’s not how the web works. You’ll be able to see the html code. Make sure all your secret stuff is on the server side, not the client side.
Hope this gives you some things to try/lookup 🙂
Have fun!

Another thing to note is you cannot really trust anything client-side since anyone who visits your website has access to your client-side code. You wouldn’t want to use client-side javascript to verify a user’s password because a malicious user could edit the javascript to accept any password.
With things like Node.js you are now using JS server-side. You don’t need to couple the language to its client/interface.

How would you send email or store things in a database with just client side JavaScript? That’s basically the type of problem that PHP solves.
Just read this amazing write-up that explains the parts a web-server and a browser are responsible for when showing you a web page.
In short: PHP sits on the server and javascript/html/css are rendered by your browser

I’ve done the guts of a CS Degree and I know what you mean. However, I came to it from already having written a lot of PHP, SQL, JavaScript, HTML, CSS etc.
The SQL bit is what really makes PHP come to the fore. You can write dynamic sites with just JavaScript. I used to create sites with no pre-wriiten HTML or (later) CSS. I could create 50+ pages from one JavaScript (.js) file and another data (.js) file.

I have PHP scripts that write HTML, JavaScript and CSS based on the results of a SQL query. (everyone does…)
PHP is the way (or the most popular way) we have of connecting a semi static HTML page (written by a PHP script) to a database. You can send data to the DB directly using PHP that outputs nice HTML/CSS for the browser response or you can use JavaScript/AJAX to do it on the fly behind the scenes.

Either way, PHP at it’s core has so many ways of either acting like a go-between from browser to DB, random stuff and HTML. Outputting something to the broswer (in HTML, JavaScript or CSS, probably other things), taking Inputs from forms, clicks or other user interactions and processing them in a multitude of ways before presenting a simple HTML/CSS/JavaScript response to the browser.
I have PHP scripts that build HTML based on SQL queries.
I have PHP scripts that build CSS based on SQL queries.
I have PHP scripts that build JavaScript based on the time of day and some other obscure measure. (and many other reasons)
I have PHP scripts that do their (my) measured best to strip the shit out of user input and cleanse all data before it gets sent to a database.
“Enter a whole number here…” does not help, trust me!
“2.656 bedrooms” comes to mind for some reason…
I’m going to guess that you could probably send JAVA code from PHP to a browser if you had run out of razer blades.

Write PHP that loads your HTML and inserts your data from a query or inserts into your database from your HTML. Beyond that, trust me, your sanity and pay scale is at risk.
The mad side is really, really cool, the sky is well below the limit. Frameworks are for slackers (unless you write your own, ever made your own prawn cocktail and then wondered why you are eating only sauce and lettuce? It’s all in the title, usually.) #boom#
It might help your understanding to have a little historical backgrounds.
In the beginning, HTML pages were static– they didn’t do anything. They were like printed pages in a book or magazine. You could have text, pictures, some elements like a dividing line, or a table. There were also forms, but when you filled out the fields, and hit submit, you just got another static page.

If you made a web page using pure HTML, no javascript or css animations, that’s all web pages originally did.
That started changing when people began to use PERL, mostly, to examine user input, and dynamically generate a page based on what the user clicked on, what time it was, etc. PERL was a server-side language, and when the web request came in, the Apache web server sent the data to a PERL script, which generated the HTML response.

PHP was originally presented as a scripting language, a sort of quick-and-dirty easy way to get the dynamic responsiveness of PERL scripts without having to write full-blown PERL. It stands for Hypertext Preprocessor; how the initials got into the order of P-H-P, I don’t know.
Without server-side languages, you couldn’t store user-submitted data in a database, send an email when a user clicks ‘submit’, return search results, or calculate a mortgage.

The fact that there wasn’t much interactivity with web pages seemed like a big opportunity, so javascript was written. Like PHP, it was originally intended to do sort of small scripts, but on the browser side, so you didn’t have to wait for data to travel through the internet (we didn’t always have fast, cheap internet), and it used the end-user’s computing power instead of the servers (we didn’t always have cheap hosting, either). People used it for more and more things, browser-side, and it became more and more powerful.

With js running in the browser, you could have things like a mortgage calculator running in the user’s browser, instead of hitting the server to do that kind of calculation.
At the same time, design was seen as a problem. With HTML, the only way to organize a web page from a graphic design perspective was HTML tables, and hacks such as images for spacing. These solutions were obviously limited, so css grew up as the response to that.

Along the way, there were some technologies that addressed some of the problems, but have since fallen by the wayside. There was JSP, which was java that ran in the browser. With a full-fledged programming language, it allowed programmers to do more interactive things in web pages than ever before. But it was eclipsed as javascript developed more and more features and capabilities.

Flash was the solution throughout the 2000s for delivering good design, interactive applications, and even games, but it was a totally separate tech stack, and didn’t necessarily integrate and play well with HTML and the rest of the web stack. It was eclipsed by javascript, in terms of gaming and interactivity, and css for design and layout.

PHP cannot do anything javascipt/html/css can do. Each of those has its own separate role– although, these days, js really seems to have taken up the most room in the ecosystem. Technologies like node.js allow js to run server-side, which theoretically allows you to avoid another server-side language, such as PHP.

PHP is like Java, C#, C, C++, Python it runs on the server and whoever accesses your website can’t see that code. You can use PHP to access database, validate users, implement APIs, make API requests from your server, etc…
JavaScript runs in your browser, it cannot handle (by itself) authentication, databases, etc… You are going to need some kind of back-end and PHP is one way to do it.

You could build websites with just PHP (you can add HTML directly into PHP files) but the end look and result would feel incredibly outdated as PHP itself is not suitable for building dynamic content. Note that PHP is not the only language you can use to create the backend of a website. There are many other languages you can use, e.g. Java.
PHP code is not seen by the end users of a website, because PHP is executed directly on the webserver. In a nutshell (a lot of simplifications here), the web server gets a request. (a HTTP request), it checks the resource requested and either loads the requested resource, or gives you a 404 page.
Likely that the webserver configuration is such is that all requests that match the pattern *.php should be forwarded to the PHP interpreter. The php engine itself can be a module installed on the webserver (e.g. the php module in apache webservers).
Then, the PHP engine interprets request that is, it executes the file by processing it top to bottom, line by line. The results are sent back to the web server, which passes the results to the end user’s browser.
So when the user fills in a form in a website, the details of the form are sent to the backend as part of a HTTP request, a common way to send these requests in JavaScript is done with the use of ajax. In bash and PHP you can use curl(bash)/curl(PHP) to send HTTP requests.

EDIT: Some extra notes that might be useful for you. JavaScript is sent to the end user as the result of a HTTP request. (your browser makes a GET request to fetch a javascript file, the webserver sends it to you) What this means is that the JavaScript is actually executed by the engine of a web browser, and the webserver just sends the javascript files to the end user as-is, without executing any of it.

This means there are some things that you can not do with JavaScript code. E.g. if you want to fetch data from a database, you’d have to do that on the backend with PHP, Java, etc.
How much was paid the CS school, lmao
Computer science curriculum is well known to be insufficient to make graduates job ready. The best schools know this and highly encourage students to get an internship or at least find a real-world web dev job if possible to gain the experience you won’t get in a classroom.

CS has its place, but there’s a reason so many trade school-like services have sprang up promising to teach people how to code and find a job. CS degrees spend a lot more time on theory and general stuff and not so much time on applicable job skills
PHP is meant for any server side operations you wish to execute. Javascript is typically client side operations, though you can also run it on the server side. Hiding the code is somewhat of a simplistic explanation to what is happening.

Php is server request code. It executes exclusively at runtime, before the web page is rendered. It’s largely used to retrieve and manipulate data from a database via SQL queries, but it has functions for retrieving data from other sources as well (file I/O, etc).
Using php, you can structure a website to run on a framework of templates, switching variable data into a single webpage (termed as a ‘view’) from a database. You can set the conditions for switching in the data using OOP or a sequential framework (model), depending on the size of your project.
I am a junior developer, giving the most basic summary possible. Php has been in active development since the nineties, and I will never fully understand it’s potential. A lot of people hate it, because… Um… It’s… Weird? As far as programming goes? Like I said, it only executes on page load, meaning you get the barest of dynamic functionality on the front end, which means you need to be familiar with front end languages as well (JavaScript / jQuery cover the basics, but firms these days expect everyone to know every typescript framework, which is an entirely different can of worms)

Basically, there’s no simple way to answer this question. Your best bet is to watch some tutorials, and figure out a way to apply it to your projects. I use LinkedIn learning, personally, but that’s a far cry from a proper boot camp. Good luck.
I am a junior developer, giving the most basic summary possible.
You’re doing a pretty good job of summarizing! Also an indication is all you can really do in this case. Don’t be too hard on yourself. Also the biggest difference between juniors and seniors is experience (well that’s what it comes down to anyway), so the path to seniordom is straightforward in that respect!
Php has been in active development since the nineties, and I will never fully understand it’s potential.
See the previous remarks, you’ll get there with experience. All you have to do is keep growing bit by bit and it adds up faster than you might expect.
A lot of people hate it, because… Um… It’s… Weird? As far as programming goes?

That’s part of it. In my own opinion there are things in every language that are weird. Some say PHP has too many of those things. I say people ought to try Perl – folks seem to like that fine for some reason.
Another part of it is that some of the most vocal people touched PHP once ten/fifteen years ago and decided they want no part of it, and now they don’t want to hear that PHP isn’t shit anymore – joking about it is easier than revisiting an opinion for some.
Having said that, there are a lot of shitty PHP developers out there, and some people may be Java developers who have to maintain an old project written by someone who did not know what they were doing – that can be very very frustrating indeed, and those folks may criticize PHP for making it possible to build that sort of crap in the first place, and having to learn a new technology doesn’t help in a situation like that. Again that’s a pretty unpleasant experience and I can see why someone might hate PHP for it.
The answer to this, in my own opinion, is that PHP is very accessible and it’s easy to quickly whip something up. The question is whether or not that’s a bad thing. I don’t think it is, but I do think that even if people do, athey should realize that building decent OOP applications is perfectly feasible in PHP and it will outperform many other technologies. Also it’s not like it’s impossible to write shit code in Java or Python.
Thanks for reading all of that. 🙂
Php in web development, is like the engine in a car.
It brings dynamic content to the web page. It runs exclusively on the server, so the clients don’t have access to it, they only see the result of the execution of a php script ( yes it is a scripting language), but at the same time it doesn’t have access to the clients browser directly, like let’s say javascript. Technically php can output anything, but usually it generates and outputs some form of text, for example HTML, CSS, JSON which the clients consume. The client can also be anything, a browser, another server, mobile application etc. Btw more than half of the web runs on php

Edit: the point of all this is to generate dynamic content. For example, you have a gallery with 1000 pictures, if you to write it in HTML, ot will be a big task, with php, just fetch the urls from a db, file/folder structure or even a simple txt file on the server, loop them and generate the HTML to display the gallery

php can generate whole pages, but they are not very interactive on the front side, i.e. the pages change when a get or a post is done to reload the page. You can use a minimum amount of javascript(jquery) to make them interactive, but if you want web pages that act like desktop applications it is better to use a front-end framework like react or vue.
Make a http request with telnet and things will be more apparent: what is client-side, what is server-side. (already explained by other replies)

source