Refactor a PHP if else statement into a ternary
lessonDuration 3m 33s
An if statement that depends upon the logic of a boolean can be simplified into something called a "ternary", which can lead to more concise & readable code.
Browse
Find courses, lessons, articles, talks, and podcasts.
7,176 resources
Showing 1,081–1,104 · Page 46 of 299
lessonDuration 3m 33s
An if statement that depends upon the logic of a boolean can be simplified into something called a "ternary", which can lead to more concise & readable code.
lessonDuration 3m 36s
Writing if statements alongside your HTML can be confusing to process. Because of this, PHP supplies an alternate if/else syntax for outputting PHP alongside HTML.
lessonDuration 1m 48s
Every programming language has the concept of conditional statements. In this lesson, we will go over how to create if statements in PHP.
lessonDuration 3m 28s
Booleans toggle variables to true or false, depending on the outcome of the expression. You can also negate values, which reverses the polarity of the PHP variable.
lessonDuration 4m 40s
Variables are great, but sometimes you need to be able to set a value in PHP, and ensure it never changes. Constants to the rescue!
lessonDuration 1m 38s
Concatenating strings together can sometimes be hard to read. As an alternative, you can use string interpolation to output variables within strings in PHP.
lessonDuration 3m 8s
Joining two strings together is something you will do a lot in PHP. Learn a few different ways to concatenate strings together.
lessonDuration 2m 48s
Sometimes internet programming languages such as JavaScript & PHP do something funky when working with variables. Learn about this "type juggling", and how it works.
lessonDuration 2m 5s
Sometimes PHP's automatic data type assignment just doesn't work for your needs. In this case, you can cast a type to a specific variable.
lessonDuration 1m 53s
PHP's echo statement is so common, it comes with an alternate "short echo tag" syntax. Let's learn how to use this syntax to clean up our view code.
lessonDuration 1m 8s
There is a difference between PHP functions and language constructs. Let's go over how to call them, and usage with & without parenthesis.
lessonDuration 2m 58s
Closing tags and semicolons play an important part in the execution of PHP code at the time of execution. We'll learn all about them as well as line breaks in this lesson.
lessonDuration 2m 1s
What's a tutorial without a hello world lesson? Let's learn about open and closing PHP brackets, and the "echo" language construct, which is perhaps the most-used construct in the language.
lessonDuration 2m 36s
Usually when you are building a website, you’ll have a web server such as Nginx or Apache that sits in front of the PHP service. But in this lesson, we’ll use a much simpler method: use the built-in PHP web server!
lessonDuration 2m 40sFree
Logged in vendors need a way to create a new shop to sell products on. This lesson will do some presentational code set up before we interact with the database. We'll create a button that we conditionally show to logged in users, create a new page, and walk through a new shops form component.
lessonDuration 2m 54sFree
There are 2 different ways to get a document's ID when using `@angular/fire`. You can add the parameter `{ idField: 'id' }` to your collection when using the `collectionData()` observable. You can also use the observable `collectionChanges()` and access the internal metadata of the document to manually get the ID and add it to the resulting object. Code sample: https://github.com/javebratt/angularfire-idField
lessonDuration 1m 3s
🚨 **Update: grid-column-gap, grid-row-gap, grid-gap have all changed to be [column-gap](https://developer.mozilla.org/en-US/docs/Web/CSS/column-gap), [row-gap](https://developer.mozilla.org/en-US/docs/Web/CSS/row-gap), and [gap](https://developer.mozilla.org/en-US/docs/Web/CSS/gap). Behavior has not changed. Just swap out the syntax and it will still work.** 🚨 You can check your results of [lesson 02 challenge](https://egghead.io/lessons/css-introduction-to-css-grid-rows-and-columns-with-display-grid?pl=build-modern-layouts-with-css-grid-d3f5) with the starting code in this lesson! I added 3 rows and columns to my grid. You can see that when we have a border on the boxes in our grid that they are all stuck together. This doesn't look great so let's fix it. CSS Grid gives us a great tool to do just that. We will apply `grid-column-gap` and `grid-row-gap` to specify the space in-between our columns and rows. ### Lesson Challenge CSS Grid gives us a shorthand version of what we used in the lesson to apply the same styles in one line instead of two. Your challenge is to use `grid-gap` to apply the same style in just one line. Play with the gap size to see the styles in action! Hint: row comes first!
lessonDuration 3m 43sFree
We are ready to create new shops for our vendors. To do this we'll define a `CreateShop` mutation that will take in all the data that our form provides. Then `useMutation` will accept that mutation and give us a function to pass our data into as well as give us the new created shop data. We'll pass in user information that we get from Auth0. This lesson finishes up with an error because Fauna doesn't know if the request came from an authenticated user or not. We'll solve this with dynamic headers in the next lesson.
lessonDuration 4m 56sFree
Now is time to use actual data product data to create and display products on a page in Next.js. Similar to before, I'll create a `ProductsList` component which will have styles and structure predefined. Look through the component in the code to get an idea of what's going on here. There are a couple updates we'll have to do with Fauna to accomplish this. First you'll notice that there is no 'getAllProducts' query that is available to us. To create such a query, we will update our schema with a `query` of `getAllProducts` that returns an array of products. We'll test it out in the GraphiQL playground and add it to Next.js. The first time you run a query like this, you'll notice you get a permission denied from the fauna endpoint. This is because we need to update our permissions to include the new index that Fauna made for `getAllProducts`. Once we do that we'll be in business.
lessonDuration 4m 44sFree
You will implement stripe checkout in your application so that customers can buy products. To do this, you will first create a Next.js API route that starts a stripe session and passes in products that are in the cart. This will forward users to the Stripe checkout page where they can input their credit card information. Upon success or cancel, stripe will forward the user back to urls that you set.
lessonDuration 6m 18sFree
Each shop will need to have products added to it by the vendor. To do this we'll need to dynamically create pages based on which shop we want to add to. Next.js has dynamically routing that we will utilize here. We'll set the shop id as the dynamic portion of the route and display a new product form. Here we will create that product form component and use Apollo `useMutation` like we did before to take in the form data. You'll notice a new keyword in our mutation query `connect` which we can use because we have a `@relation` set between products and shop. This connect will associate the product to the shop through the id that we grab from the route.
lessonDuration 6m 1s
We’ll explore how constructors and prototypes are used to create and share properties in JavaScript objects respectively, as well as how the introduction of classes and subclasses with ECMAScript 2015 lets use develop clean, secure object-oriented code.
lessonDuration 5m 10sFree
We'll use [Auth0's Next.js quickstart guide](https://auth0.com/docs/quickstart/webapp/nextjs/01-login) to add authentication to our application. While doing so, we'll create and set all the right keys that we will need, create an auth api route, wrap our application in a `UserProvider` component and finally add a login button that uses Auth0's hook they provide.
lessonDuration 6m 34sFree
We want visitors to our site to be able to browse our products and add them to a cart for purchase. To do this we'll create React Context to expose a cart value to our application so we can use it where we need to. This context will handle adding items and deleting items from the cart. We will hook up the add functionality to buttons on our product cards as well as display how many items we have in the cart in our Nav bar.