Alternate PHP if statement syntax for view files
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.
Browse
Find courses, lessons, articles, talks, and podcasts.
54 results for "php"
Showing 25–48 · Page 2 of 3
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 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 1m 58s
There are many different options when it comes to choosing a PHP editor, from Notepad to VSCode to PHPStorm. Let's pick an IDE and create our project folder.
course
lorem ipsum
lessonDuration 4m 1s
Class properties and methods can have different visibility levels, which control how private or protected those properties are.
lessonDuration 1m 34s
Sometimes you need to group together pieces of code. That's what functions are for! In this lesson, we'll learn all about them.
lessonDuration 4m 12s
When you find yourself repeating or writing similar conditional logic in your if statements, a better option may be a switch statement.
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 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.
article
Hey Everyone 👋, John Lindquist here with the second issue of AI Dev Essentials! It's been another busy week in the AI tooling world. The biggest splash was probably GPT-4.1 hitting the streets, but there's plenty more action around MCP, Vercel's v0, Google's developer tools, and interesting community discussions. I've spent some time with GPT-4.1 already (specifically in Cursor), and while it shows promise, it didn't quite convince me to switch from Gemini 2.5 Pro yet. It stumbled on a few basic requests where Gemini usually shines on the first attempt. --- ### New egghead.io Lesson This Week: * **[Create a Custom MCP that Calls Cursor Tools](https://egghead.io/create-a-custom-mcp-that-calls-cursor-tools~r77sw):** Learn how to build custom MCP server tools that allow Cursor's AI Agent to access your local project context. This lesson shows how to use Zod schemas and the crucial `.describe()` method to explicitly request information (like Git status or version) from the Cursor environment *before* your tool runs, enabling powerful, context-aware automation. --- Here are the highlights that caught my eye this past week. ## Model Mania: GPT-4.1 Arrives, Plus Grok & Llama Updates * **GPT-4.1 Lands:** OpenAI announced GPT-4.1, and it quickly became available via the [API](https://openai.com/live/) and showed up in [Cursor](https://x.com/cursor_ai/status/1911835651810738406). Cursor is offering it free for now to let users get a feel for it, though they don't recommend it as a default just yet. Curious to hear initial impressions from folks testing it out for coding tasks. * **Grok 3 in Cursor:** Following other model additions, [Cursor also enabled Grok 3 models](https://x.com/amanrsanger/status/1910434915419906141), with the mini version available for free users. Aman Sanger noted it seems to "think upfront more than other models." * **Community Hack: Llama 4.0 via Groq in Cursor:** Levi Dan shared a [detailed (and slightly hacky) guide](https://x.com/lxvi_brg/status/1908865544721154455) on how to wire up Groq's fast Llama 4.0 API into Cursor by using the OpenAI API key slot and intercepting requests. A clever workaround for the adventurous! ## Tooling & Platform Pulse Lots of movement across different platforms and tools this week: * **Vercel Ecosystem:** * Guillermo Rauch teased [v0 coming to VS Code](https://x.com/rauchg/status/1911524154458984515), hinting at tighter integration for the UI generation tool. * v0 also [added AI integrations](https://x.com/v0/status/1911912183149256943) with models from xai (Grok), FAL, Groq, and DeepInfra, including automatic API key setup and pay-as-you-go billing via Vercel Marketplace. They're offering a $10 credit for the Grok free tier. * Vercel shared insights on the [grep.app migration from CRA to Next.js](http://grep.app/), showcasing performance improvements. ([Source](https://x.com/rauchg/status/1911920410020757881)) I'm personally excited about this one – I rely heavily on examples when working with AI, and for me, a good example is often worth ten prompts. Tools like `grep.app` that make code discovery easier are invaluable. * **Google's Growing Stack:** * Project IDX has officially become [Firebase Studio](https://x.com/_davideast/status/1909990728593453455), positioning itself as a cloud-based, agentic dev environment for full-stack AI apps, deeply integrated with Firebase. I've tried spinning up a few sites with it, and the speed is impressive. However, for more complex tasks like designing from images or intricate interactions, I still find myself leaning towards v0 for now. * Google quietly released the [Agent Development Kit (ADK)](https://x.com/omarsar0/status/1910004370864742757), a Python library (`pip install google-adk`) for building multi-agent systems with features like state management, tool usage, and orchestration. I haven't had a chance to dive into this yet, but it's right at the top of my list. Building robust agent systems is a huge area of interest, so this is probably the announcement I'm most excited about exploring this week. * Ramón Medrano Llamas shared his experience [moving back to VS Code from Cursor](https://x.com/rmedranollamas/status/1909516749612999149), highlighting the effectiveness of GitHub Copilot combined with the Gemini Code Assist extension (using Gemini 2.5 Pro in Agent Mode). I gave the Gemini Code Assist extension a try myself, but as someone deeply embedded in the Cursor workflow with established keyboard shortcuts and patterns, I struggled to find a flow I liked and didn't stick with it for long. It's interesting to see different perspectives, though! * AI features are rolling out more broadly in [Chrome](https://x.com/iam_chonchol/status/1909942954686636224), including text grabbing from YouTube videos and Google Lens integration. * **Cloudflare Corner:** * Big news for edge compute: [Cloudflare Containers are coming to Open Beta in June](https://x.com/CherryJimbo/status/1910682562499850405), enabling running containerized apps (Next.js, Go, PHP confirmed) directly on the edge. This is huge news, in my opinion. Think about all the WordPress sites and other applications that rely on containerization. Opening this up on the edge unlocks incredible possibilities, including for AI applications. I'm super hyped to see what people build with this come June. * A new tool, [MCPify.ai](http://mcpify.ai/), launched for building MCP servers conversationally, built entirely on Cloudflare Workers and Durable Objects. ([Source](https://x.com/pbteja1998/status/1911723180445610149)) * Securing MCP servers is getting easier, with examples shared using [WorkOS AuthKit](https://x.com/WorkOS/status/1910722639036874943) and [Auth0](https://x.com/dschenkelman/status/1910693265566728319). * **IDE Updates:** * JetBrains shared the public [WebStorm roadmap for March-April](https://youtrack.jetbrains.com/issue/WEB-72310). ([Source](https://x.com/WebStormIDE/status/1909291367504748937)) > **✨ Workshop Spotlight: Conquer the Complexity of Cursor (Europe Friendly Time!) ✨** > > Missed the last workshop or found the timing tricky? This one's for you! Master practical AI development workflows in Cursor in a session scheduled for **12:00 PM UTC** to better accommodate European attendees. > > This hands-on workshop covers Agents, Ask, Custom Modes, multi-file analysis, effective prompting, Cursor rules, and strategies for handling AI failures. Unlock Cursor's potential and streamline your development process. > > * **When:** \[Check website for upcoming dates - This session is Europe-friendly at 12:00 PM UTC\] > > * **Where:** Zoom (Live Q&A included) > > * **Investment:** $149 > > ➡️ [**Read More about the Workshop**](https://egghead.io/workshop/cursor) > ➡️ [**Register Now ($149)**](https://buy.stripe.com/7sI7tT81dfpC06s28c) > > *(Team training also available)* ## Community Buzz & Resources * **MCP Explained:** Kent C. Dodds wrote a piece explaining [why he's excited about Model Context Protocol (MCP)](https://www.epicai.pro/the-game-changing-potential-of-model-context-protocol) and its potential. ([Source](https://x.com/kentcdodds/status/1911840456432034112)) * **Prompting Guide:** Ian Nuttall surfaced [v7 of Google's Prompt Engineering Guide](https://x.com/iannuttall/status/1911086164196606314), a deep dive into techniques and best practices. Definitely worth a look. * **Discussion Starter:** Eric Zakariasson asked the community about their [favorite CLIs and MCP servers to use with the Cursor agent](https://x.com/ericzakariasson/status/1910808935961088346). What are you all using? * **Gemini 2.5 Pro Praise:** The positive buzz around Gemini 2.5 Pro continues to grow in the community. It's getting rave reviews and even achieving 'S-tier' status on social platforms like Reddit for its coding capabilities. ([Source](https://x.com/suchenzang/status/1911251230317490416)) That’s a wrap for this week! There's always so much happening, it's hard to keep up, but hopefully, this helps surface some of the more interesting bits for developers working with AI. If you have any feedback or questions, feel free to respond to this email. Always happy to talk shop about the latest AI tools. John Lindquist [egghead.io](https://egghead.io)
article
This is a milestone release for both Next and React with one of the first chances we've had to develop web applications using React Server Components (RSC). At Next Conf 2022 both the teams from Meta and Vercel were present and excited to finally get React Server Components deployed to production. There has been some mild controversy suggesting that Vercel and Next have received special treatment from the React team. What isn't obvious is that the React team is no longer only at Meta. Vercel employs at least two full-time developers including [Sebastian Markbåge who left Meta to join Vercel in 2021](https://vercel.com/blog/supporting-the-future-of-react). This means that Vercel is as much part of the React team as Meta. For the rest of us that aren't part of the React Core team, this is good news. React is being funded and deployed outside of the context of how Meta uses the library to build Facebook. The core interests of the React tool are diversified. It's healthy. ## Upgrading to Next 13 Next 13 introduces a new paradigm of routing and layouts that makes use of React Server Components. **This feature is released in Next 13 as a beta.** You can upgrade to Next 13, but that doesn't opt you or your team into using the new layouts and server components today. [egghead is a decent-sized Next app](https://github.com/eggheadio/egghead-next), and we are planning to upgrade to Next 13 and take our time exploring the new layouts and server components since it is a radical shift in how we approach building our application. ## Comparisons to "old school PHP" PHP has been the butt of jokes for years, but still drives a huge portion of the internet. One of the coolest things about PHP that likely drives a lot of the comparison is that you could have your SQL right there next to your markup. Inline. In context. React Server Components have that feel. Kent C. Dodds writes about this in his excellent article [Full Stack Components](https://www.epicweb.dev/full-stack-components). Kent is sharing this paradigm in the context of Remix. There are a handful of core differences. The Remix team ([acquired by Shopify](https://shopify.engineering/remix-joins-shopify) who maintains [Hydrogen](https://hydrogen.shopify.dev/)) is not betting on React Server Components, though they have said that they will support them as they mature more. Full stack components feel great though, and I think we'll see much more of this paradigm over the next several years. ## Open Source Ecosystem Ripple Effects There is no doubt that there will be ecosystem ripple effects with the introduction of React Server Components. Libraries like react-query and tRPC are the first to spring to my mind, and the massive amount of work those maintainers are facing to understand and support the incoming paradigm shift. It's s a good time to check in with your favorite maintainers and pitch in where you can. ## Exciting times to be a nerd The constant here is change and evolution. We benefit from a mountain of choice, but that choice can be a burden. All of these ideas are building on the past, and it's exciting to watch what is changing and what is staying the same. <Course slug="build-static-pages-dynamically-using-next-js-and-the-notion-api-34849fc4" />
podcast
<p>Jen Luker is a software engineer at Formidable Labs Inc. She has worked as a full-stack developer using PHP, Javascript, and CSS, but has a particular fondness for frontend technologies.</p><p>Today, we discuss the issue of accessibility and how focusing on making websites and software more accessible should be a constant consideration, particularly since it taps into an underserved market. Tune in to hear on discussion on this vital and fascinating topic.</p><hr /><h3>Transcript</h3><p><a href="https://egghead.simplecast.com/episodes/6191c97e/transcript">"Jen Luker, a11y champion" Transcript</a></p><h3>Topics:</h3><ul><li>The Internet and accessibility</li><li>How loading times affect accessibility</li><li>How accessibility helps everyone</li><li>Missing out on business by not being accessible</li><li>The importance of making accessibility a regular part of the conversation</li></ul><h3>Quotes:</h3><blockquote><p>“One of the benefits of incorporating a lot of these accessibility features is that they end up helping everyone.” -Jen Luker</p></blockquote><blockquote><p>“Only about one in ten websites, according to an audit that DQ did, is accessible.” -Jen Luker</p></blockquote><h3>Resources:</h3><ul><li><a href="https://formidable.com/">Formidable Labs Inc.</a></li><li><a href="https://www.deque.com/axe/">Deque aXe</a></li></ul><h3>Jen Luker:</h3><ul><li><a href="https://www.jenluker.com/">Website</a></li><li><a href="https://twitter.com/knitcodemonkey?lang=en">Twitter</a></li><li><a href="https://github.com/knitcodemonkey">Github</a></li></ul><h3>Joel Hooks:</h3><ul><li><a href="https://twitter.com/jhooks">Twitter</a></li><li><a href="https://joelhooks.com/">Website</a></li></ul>
lessonDuration 35m 42sFree
### **Have you authored a State Management library?** - Yes. Animation is entirely State. Moving from State to State in a fluid manner, dealing with interruptions. [Animated · React Native](https://reactnative.dev/docs/animated) - The Animated library is designed to make animations fluid, powerful, and painless to build and maintain. - Animated focuses on declarative relationships between inputs and outputs, configurable transforms in between, and start/stop methods to control time-based animation execution. - **The notion of physically-based animation.** - Physically-based animation is an area of interest within computer graphics concerned with the simulation of physically plausible behaviors at interactive rates. - Native applications are using "springs." Similar to a real springs (physically-based animation). It feels more real life, and it the way how iOS has implemented animations. - Problems occur when you need to apply this on the framework level. - If an animation is interrupted, it will result in a choppy animation. **This is due to JavaScript being single-threaded.** - The way native platforms are solving this problem is by moving this process to a different thread. - What we have done for Animated is that you define the animated values, then those values are sent to be computed in the dependency tree on a separate thread. - Now the challenge is how do you make declaring animations easier. ### **Is there a correlation between State and the *processes*? What layer of State is that?** - The difference between Animated and Recoil lies in how you update the DOM elements. - With Animated, we want to update the final DOM elements. - Recoil is a very low level of that implementation. You need to have find grain dependency management. - **Recoil works and thinks like React.** It uses the React component states and updates them. - The atomic unit that you are working on now is a React component. - You don't have to invent your own implementation. You can directly target specific React elements without reloading the entire tree. ### **What collaboration and resources came to inform this solution?** - Animated didn't inspire Recoil. The actual libraries are really small. The problem is how you educate people to start working with these libraries. ### These are complex problems. What are the common patterns when solving State Management? - **Recoil got inspiration from React Hooks.** - With Recoil, you are able to do the same thing as useState but also have access to a regular JavaScript object that you can pass around. - This has the benefit in that you no longer need to take over the whole JavaScript bundle. ### **What are the types of State that you have in an application?** - The first phase of State is the external data source that you get from the server. - For this type of State, Relay and GraphQL are excellent solutions. GraphQL is declarative. Relay handles local caching - transferring data between minor updates. And Relay is a superb solution to update specific components. ### **Why is Relay not the go-to solution?** - With Relay, you need to have a GraphQL backend. No easy way to create an integrated compatible backend solution. - At a conceptual level, we can think about Relay, GraphQL, and Apollo as the same, but at the implementation level, they differ from each other. - At the end of the day, the technology that you choose to work with will create constraints for your application. - **How you fetch data will affect the rest of your application.** - Gatsby uses a Relay-like implementation to build the Graph from 20-something data sources - but they make that invisible when building those structures. - Another type of website is CRUD apps that want more complex forms. There are no good solutions to manage forms. In the past, Redux was used, but it didn't solve the problem. - PHP, Rails, WordPress let you generate forms and manage them nicely on the backend. - Recoil solved problems for Formik. Managing states and updates in nested forms. [Jared Palmer and Joel talk about State Management](https://www.notion.so/egghead/Jared-Palmer-and-Joel-talk-about-State-Management-20676ba02a8b4484912e3b59d77c742c) ### **Have you ever explored Falcore?** - Yes. Falcor is a real-time rendering framework supporting DirectX 12. It aims to improve the productivity of research and prototype projects. [NVIDIAGameWorks/Falcor](https://github.com/nvidiagameworks/falcor) - The idea with Falcor is that we can do the same thing without having a solid schema (Dynamically importing REST points.) - This solves the same issues when managing State, and it lowers the barrier of entry. ### **What State Management problems did you run into when building Excalidraw?** [Excalidraw](https://excalidraw.com/) - The initial plan was to use Recoil. The solution was to create one JSON file to manage the state. Then re-render the whole tree. - It worked pretty well until we wanted to update different parts at different rates. We wanted the interaction to be faster and making caching easier. - Recoil would have handled this for us, but we took a different approach; we started building tooling with pure React and JavaScript. - We didn't want to add additional features that would make it slower. - We implemented the core features from other libraries to avoid adding additional dependencies. - This is a design feature; you can start designing backward. - **Optimizing** - At WhatsApp, we optimize by writing small amounts of code and adding little to no dependencies. - Facebook takes a different approach. They iterate fast, so they are implemented in multiple libraries. - **Both are successful but with different strategies.** ### **When you are doing optimization at scale, is State Management part of that?** - State Management is part of the conversation. But it's not critical since this is not likely to change much. - For example, when we re-wrote Facebook from PHP to React + GraphQL + and server-side rendering. The underlying architecture did not change much. - **To improve the performance, you need to measure it**. - Our team has focused on measuring performance in testing, production, etc. Once we have those measurements, we can start implementing tools to track performance. - Many teams own different parts of Facebook. We take all of those metrics and put them in a program where executives can review the status. - **It's State Management at a business level. Everything is moving-different components.** - If you give a Metric to an engineer, they will drive it down. They are excited to make it fast. It's important to track it. If you want to improve performance, you need to track it, improve it, and show it to management.
lessonDuration 3m 38s
Different from a foreach loop, a for loop in PHP allows you to iterate through an array based on an index or another conditional value.