This Book guides the embedded system hobbyist to develop an web based application integrating with Embedded system . Beginner can create custom based HMI or GUI using PHP web application , also you create IOT based application.
PHP was created in 1995 by Rasmus Lerdorf to track visitors to his personal website. It has since grown tremendously in popularity and functionality. This book aims to teach PHP to both experienced and novice readers, covering all aspects of the language from basics to object-oriented programming and database integration. The intended audience includes those with web experience but no prior programming knowledge.
This document provides an introduction and overview of PHP 5. It covers setting up a development environment using XAMPP and NetBeans, and includes examples of basic PHP scripts. The document demonstrates how to output text from PHP code, use comments, and pass data between the server and browser. It also introduces PHP variables, forms, operators, and control structures. Later sections discuss object-oriented programming in PHP, MVC patterns, and interacting with MySQL databases.
The document provides instructions for installing PHP and configuring it with Apache on Linux or Unix systems. It outlines downloading and installing the necessary components like the PHP source distribution, Apache source distribution, and a PHP-supported database. It then describes the steps to build and configure Apache to work with PHP, including compiling and installing PHP, copying the php.ini configuration file, and configuring Apache's HTTPD configuration files to identify PHP files and set the document root directory. Once completed, the PHP installation would be ready for use on the Linux/Unix system with Apache.
The document provides instructions for installing PHP, Apache web server, and MySQL database on Linux/Unix systems to set up a development environment for PHP web applications. The steps include downloading and compiling the latest versions of PHP and Apache source code, configuring PHP to work with Apache as a module, and setting the PHP configuration file and document root directory. This will allow PHP scripts to be processed and run on the local development server.
This document provides an overview and introduction to PHP, including its uses, environment setup, syntax, variables, operators, and basic decision making and loop structures. PHP is a programming language used for web development that allows dynamic content and interaction with databases. This tutorial will help readers understand PHP basics and implementation. It requires knowledge of programming, internet, databases and MySQL.
The PHP Hypertext Preprocessor (PHP) is a programming language that allows web developers to create dynamic content that interacts with databases. PHP is basically used for developing web-based software applications. This tutorial will help you understand the basics of PHP and how to put it in practice.
The document provides instructions for installing PHP, Apache web server, and MySQL database on Linux/Unix systems to set up a development environment for PHP web applications. It describes downloading and compiling the latest versions of PHP and Apache source code, configuring PHP to work with Apache as a module, and setting the PHP configuration file and document root directory. This allows PHP code to be embedded in HTML files and executed by the Apache web server to create dynamic web pages that can also interface with the MySQL database.
This document provides an overview and introduction to PHP, including its uses, environment setup, syntax, variables, operators, and basic decision making and loop structures. PHP is a programming language used for web development that allows dynamic content and interaction with databases. This tutorial will help readers understand PHP basics and implementation. It requires knowledge of programming, internet, databases and MySQL.
PHP was created in 1995 by Rasmus Lerdorf to track visitors to his personal website. It has since grown tremendously in popularity and functionality. This book aims to teach PHP to both experienced and novice readers, covering all aspects of the language from basics to object-oriented programming and database integration. The intended audience includes those with web experience but no prior programming knowledge.
This document provides an introduction and overview of PHP 5. It covers setting up a development environment using XAMPP and NetBeans, and includes examples of basic PHP scripts. The document demonstrates how to output text from PHP code, use comments, and pass data between the server and browser. It also introduces PHP variables, forms, operators, and control structures. Later sections discuss object-oriented programming in PHP, MVC patterns, and interacting with MySQL databases.
The document provides instructions for installing PHP and configuring it with Apache on Linux or Unix systems. It outlines downloading and installing the necessary components like the PHP source distribution, Apache source distribution, and a PHP-supported database. It then describes the steps to build and configure Apache to work with PHP, including compiling and installing PHP, copying the php.ini configuration file, and configuring Apache's HTTPD configuration files to identify PHP files and set the document root directory. Once completed, the PHP installation would be ready for use on the Linux/Unix system with Apache.
The document provides instructions for installing PHP, Apache web server, and MySQL database on Linux/Unix systems to set up a development environment for PHP web applications. The steps include downloading and compiling the latest versions of PHP and Apache source code, configuring PHP to work with Apache as a module, and setting the PHP configuration file and document root directory. This will allow PHP scripts to be processed and run on the local development server.
This document provides an overview and introduction to PHP, including its uses, environment setup, syntax, variables, operators, and basic decision making and loop structures. PHP is a programming language used for web development that allows dynamic content and interaction with databases. This tutorial will help readers understand PHP basics and implementation. It requires knowledge of programming, internet, databases and MySQL.
The PHP Hypertext Preprocessor (PHP) is a programming language that allows web developers to create dynamic content that interacts with databases. PHP is basically used for developing web-based software applications. This tutorial will help you understand the basics of PHP and how to put it in practice.
The document provides instructions for installing PHP, Apache web server, and MySQL database on Linux/Unix systems to set up a development environment for PHP web applications. It describes downloading and compiling the latest versions of PHP and Apache source code, configuring PHP to work with Apache as a module, and setting the PHP configuration file and document root directory. This allows PHP code to be embedded in HTML files and executed by the Apache web server to create dynamic web pages that can also interface with the MySQL database.
This document provides an overview and introduction to PHP, including its uses, environment setup, syntax, variables, operators, and basic decision making and loop structures. PHP is a programming language used for web development that allows dynamic content and interaction with databases. This tutorial will help readers understand PHP basics and implementation. It requires knowledge of programming, internet, databases and MySQL.
PHP is a programming language used to create dynamic web content. It allows developers to build web applications that interact with databases. This tutorial provides an introduction to PHP, covering basic syntax, variable types, operators, decision making statements like if/else and loops. It is designed for beginners to help them understand how to use PHP.
Python is a general-purpose, interpreted, interactive, object-oriented and high-level
programming language. Python was created by Guido van Rossum in the late eighties and
early nineties. Like Perl, Python source code is also now available under the GNU General
Public License (GPL).
This document provides an introduction to PHP-Nuke, an open source content management system. It discusses the purpose and features of PHP-Nuke, including its use for websites, intranets, e-commerce, and more. The document also provides a brief history of PHP-Nuke, noting it was created in 1998 as a way to manage a news site and distribute content. It describes PHP-Nuke as using PHP and MySQL to allow users to submit and discuss content through a web-based interface.
This document provides information about customizing and programming for the PHP-Nuke content management system, including:
- An overview of PHP-Nuke's installation, structure, modules, blocks, and customization options.
- Instructions for creating new blocks and modules to extend PHP-Nuke's functionality.
- Details on PHP-Nuke's directory structure, databases tables, and security best practices.
- Guidelines for modifying themes, templates, and the user interface.
The document is intended as a reference for PHP-Nuke administrators and programmers to manage sites and develop additional functionality through blocks and modules.
This document provides an overview and tutorial on the Python programming language. It discusses Python's history and features, how to set up the Python environment and get started with the language. It then covers Python's basic syntax, variable types, operators, and decision-making constructs like if/else statements. The tutorial is designed for beginners to help them learn Python programming from scratch.
This document provides a user guide for ExeOutput for PHP, a PHP and website compiler for Windows. It allows users to create standalone Windows applications that can run and display PHP websites without requiring an internet connection, PHP installation, or remote web server. The guide covers starting a new project, developing and testing projects, customizing applications, navigating compiled webpages, accessing files with PHP, and other topics to help users build and deploy their PHP applications.
This document is a table of contents for a book about learning PHP for beginners and intermediate developers. It outlines 14 chapters that cover topics like web design basics, setting up a PHP workspace, PHP syntax, functions, arrays, strings, file handling, MySQL, object-oriented programming, and more advanced concepts. The document provides an overview of the key concepts and topics that will be discussed in each chapter.
This document provides an overview of a solution using HPE infrastructure with SAP HANA Vora, Hortonworks HDP, and Apache Spark. It describes implementing interactive analytics across SAP HANA and Hadoop data and managing data movement between SAP HANA and HDP. The solution uses HPE ConvergedSystem 500 for SAP HANA with HPE Elastic Platform for Big Data Analytics running HDP and SAP HANA Vora on HPE Apollo 2000 and 4200 servers. It aims to simplify data access and management while accelerating analytics across enterprise and big data.
HPE Reference Architecture for SAP HANA Vora with Spark and Hadoop-4AA6-7739ENWViplava Kumar Madasu
The document describes an SAP HANA Vora solution using HPE infrastructure, including:
- HPE ConvergedSystem 500 for SAP HANA running SAP HANA and SAP DLM
- HPE Elastic Platform for Big Data Analytics (EPA) running Hortonworks HDP for Hadoop, Spark, and SAP HANA Vora
The solution enables interactive analytics across SAP HANA and Hadoop data using SAP HANA Vora and Spark, and manages data movement between SAP HANA and Hadoop.
This module prints a simple "Hello world 1" message when loaded and "Goodbye world 1" when unloaded. It implements the basic init_module and cleanup_module functions required for all kernel modules, which are called when the module is loaded and unloaded respectively. The module demonstrates the simplest form of a kernel module and introduces the printk function for printing from a module.
This document provides an overview and tutorial for the Python programming language. It discusses Python's history and features, how to set up the Python environment and run Python programs, Python's basic syntax including variables, operators, and control flow structures, built-in data types like numbers, strings, lists, and dictionaries, and many Python functions and methods. The tutorial is designed for new Python programmers to learn the fundamentals of the language.
The document provides guidance on integrating PHP applications with SAP systems. It details how to install and configure the necessary PHP and SAPRFC environment. It then walks through building a sample PHP application that connects to SAP and calls functions to retrieve and display data. The application is meant to demonstrate best practices for PHP-SAP integration and serve as a learning tool.
This document provides a summary of a project that developed a vendor connection web application using the CodeIgniter PHP framework. It discusses the technologies used including CodeIgniter, Bootstrap, HTML5 and CSS3. It describes the system development process, including system analysis, database design, and installation of CodeIgniter. It outlines key features of the application such as login, home page, vendor list, order status, and order viewing. The purpose of the project is to introduce CodeIgniter and Bootstrap while providing an example application for students to learn web development.
This book provides guidance on designing and building embedded Linux systems. It introduces the topic and covers important concepts like hardware support, development tools, the Linux kernel, and root filesystem setup. The book explains how to configure, cross-compile, and install the kernel. It also describes manipulating storage devices and setting up the bootloader, networking services, and debugging tools. The goal is to help experienced embedded developers customize and use Linux in their projects without relying on third-party products.
Chef is an open source configuration management tool that uses recipes and cookbooks to automate infrastructure. It follows a client-server architecture where cookbooks are developed on a workstation, uploaded to a Chef server, and used to configure nodes. Setting up Chef involves installing the Chef development kit (ChefDK) on a workstation, initializing a Git repository, and registering nodes with the Chef server to allow management via recipes and cookbooks.
This document provides an overview and introduction to Chef, an open-source configuration management tool. It discusses the key building blocks of Chef including cookbooks, roles, environments, nodes and the Chef client run. It also covers how to set up the Chef workstation, clients, Test Kitchen and Knife tools. The document is intended for those wanting to understand Chef's features and how to use it to automate infrastructure provisioning and management.
This document provides a summary of the key points from the document "Consumer-Centric API Design".
1. The document discusses best practices for designing APIs that are consumer-centric and easy for developers to use. It emphasizes data abstraction, using common HTTP methods and patterns, and focusing on the needs of API consumers.
2. The author advocates designing APIs around core CRUD concepts to abstract complex business logic and data structures. Real-world examples show both good and bad approaches to data abstraction.
3. Additional chapters will cover topics like HTTP requests and responses, API versioning, authentication, permissions, documentation and testing. The goal is for readers to understand how to build APIs that third-party developers will enjoy
This document provides instructions and examples for various HTML and SQL concepts taught in an introductory database lab course. It covers HTML topics like basic page structure, headings, paragraphs, links, images and tables. It also covers SQL topics like creating and managing tables, queries, functions, and connecting databases with PHP. The document is organized into 12 labs that progressively build skills with HTML, PHP, SQL, MySQL and PL/SQL.
This is Eight Channel relay board controlled by Bluetooth Module. The Bluetooth relay board is with 8
SPDT relays rated up to 7A each. You can control devices 230V / 120V (up to 8) directly with one such
relay unit. Suitable for home automation applications, hobby projects, industrial
automation. Bluetooth module enables you to wireless transmit & receive serial data.
4 Channel Relay Board 5V-Bluetooth Compatible for ArduinoRaghav Shetty
Bluetooth technology is a short distance communication technology used by almost all phones
including smart phones and all laptops. This technology find very wide uses including that of Home &
Industrial automation.
The Relay shield is capable of controlling 4 relays. The max switching power could be
12A/250VAC or 15A/24VDC. It could be directly controlled by Arduino through digital IOs.
More Related Content
Similar to Integrating php with embedded system - IOT
PHP is a programming language used to create dynamic web content. It allows developers to build web applications that interact with databases. This tutorial provides an introduction to PHP, covering basic syntax, variable types, operators, decision making statements like if/else and loops. It is designed for beginners to help them understand how to use PHP.
Python is a general-purpose, interpreted, interactive, object-oriented and high-level
programming language. Python was created by Guido van Rossum in the late eighties and
early nineties. Like Perl, Python source code is also now available under the GNU General
Public License (GPL).
This document provides an introduction to PHP-Nuke, an open source content management system. It discusses the purpose and features of PHP-Nuke, including its use for websites, intranets, e-commerce, and more. The document also provides a brief history of PHP-Nuke, noting it was created in 1998 as a way to manage a news site and distribute content. It describes PHP-Nuke as using PHP and MySQL to allow users to submit and discuss content through a web-based interface.
This document provides information about customizing and programming for the PHP-Nuke content management system, including:
- An overview of PHP-Nuke's installation, structure, modules, blocks, and customization options.
- Instructions for creating new blocks and modules to extend PHP-Nuke's functionality.
- Details on PHP-Nuke's directory structure, databases tables, and security best practices.
- Guidelines for modifying themes, templates, and the user interface.
The document is intended as a reference for PHP-Nuke administrators and programmers to manage sites and develop additional functionality through blocks and modules.
This document provides an overview and tutorial on the Python programming language. It discusses Python's history and features, how to set up the Python environment and get started with the language. It then covers Python's basic syntax, variable types, operators, and decision-making constructs like if/else statements. The tutorial is designed for beginners to help them learn Python programming from scratch.
This document provides a user guide for ExeOutput for PHP, a PHP and website compiler for Windows. It allows users to create standalone Windows applications that can run and display PHP websites without requiring an internet connection, PHP installation, or remote web server. The guide covers starting a new project, developing and testing projects, customizing applications, navigating compiled webpages, accessing files with PHP, and other topics to help users build and deploy their PHP applications.
This document is a table of contents for a book about learning PHP for beginners and intermediate developers. It outlines 14 chapters that cover topics like web design basics, setting up a PHP workspace, PHP syntax, functions, arrays, strings, file handling, MySQL, object-oriented programming, and more advanced concepts. The document provides an overview of the key concepts and topics that will be discussed in each chapter.
This document provides an overview of a solution using HPE infrastructure with SAP HANA Vora, Hortonworks HDP, and Apache Spark. It describes implementing interactive analytics across SAP HANA and Hadoop data and managing data movement between SAP HANA and HDP. The solution uses HPE ConvergedSystem 500 for SAP HANA with HPE Elastic Platform for Big Data Analytics running HDP and SAP HANA Vora on HPE Apollo 2000 and 4200 servers. It aims to simplify data access and management while accelerating analytics across enterprise and big data.
HPE Reference Architecture for SAP HANA Vora with Spark and Hadoop-4AA6-7739ENWViplava Kumar Madasu
The document describes an SAP HANA Vora solution using HPE infrastructure, including:
- HPE ConvergedSystem 500 for SAP HANA running SAP HANA and SAP DLM
- HPE Elastic Platform for Big Data Analytics (EPA) running Hortonworks HDP for Hadoop, Spark, and SAP HANA Vora
The solution enables interactive analytics across SAP HANA and Hadoop data using SAP HANA Vora and Spark, and manages data movement between SAP HANA and Hadoop.
This module prints a simple "Hello world 1" message when loaded and "Goodbye world 1" when unloaded. It implements the basic init_module and cleanup_module functions required for all kernel modules, which are called when the module is loaded and unloaded respectively. The module demonstrates the simplest form of a kernel module and introduces the printk function for printing from a module.
This document provides an overview and tutorial for the Python programming language. It discusses Python's history and features, how to set up the Python environment and run Python programs, Python's basic syntax including variables, operators, and control flow structures, built-in data types like numbers, strings, lists, and dictionaries, and many Python functions and methods. The tutorial is designed for new Python programmers to learn the fundamentals of the language.
The document provides guidance on integrating PHP applications with SAP systems. It details how to install and configure the necessary PHP and SAPRFC environment. It then walks through building a sample PHP application that connects to SAP and calls functions to retrieve and display data. The application is meant to demonstrate best practices for PHP-SAP integration and serve as a learning tool.
This document provides a summary of a project that developed a vendor connection web application using the CodeIgniter PHP framework. It discusses the technologies used including CodeIgniter, Bootstrap, HTML5 and CSS3. It describes the system development process, including system analysis, database design, and installation of CodeIgniter. It outlines key features of the application such as login, home page, vendor list, order status, and order viewing. The purpose of the project is to introduce CodeIgniter and Bootstrap while providing an example application for students to learn web development.
This book provides guidance on designing and building embedded Linux systems. It introduces the topic and covers important concepts like hardware support, development tools, the Linux kernel, and root filesystem setup. The book explains how to configure, cross-compile, and install the kernel. It also describes manipulating storage devices and setting up the bootloader, networking services, and debugging tools. The goal is to help experienced embedded developers customize and use Linux in their projects without relying on third-party products.
Chef is an open source configuration management tool that uses recipes and cookbooks to automate infrastructure. It follows a client-server architecture where cookbooks are developed on a workstation, uploaded to a Chef server, and used to configure nodes. Setting up Chef involves installing the Chef development kit (ChefDK) on a workstation, initializing a Git repository, and registering nodes with the Chef server to allow management via recipes and cookbooks.
This document provides an overview and introduction to Chef, an open-source configuration management tool. It discusses the key building blocks of Chef including cookbooks, roles, environments, nodes and the Chef client run. It also covers how to set up the Chef workstation, clients, Test Kitchen and Knife tools. The document is intended for those wanting to understand Chef's features and how to use it to automate infrastructure provisioning and management.
This document provides a summary of the key points from the document "Consumer-Centric API Design".
1. The document discusses best practices for designing APIs that are consumer-centric and easy for developers to use. It emphasizes data abstraction, using common HTTP methods and patterns, and focusing on the needs of API consumers.
2. The author advocates designing APIs around core CRUD concepts to abstract complex business logic and data structures. Real-world examples show both good and bad approaches to data abstraction.
3. Additional chapters will cover topics like HTTP requests and responses, API versioning, authentication, permissions, documentation and testing. The goal is for readers to understand how to build APIs that third-party developers will enjoy
This document provides instructions and examples for various HTML and SQL concepts taught in an introductory database lab course. It covers HTML topics like basic page structure, headings, paragraphs, links, images and tables. It also covers SQL topics like creating and managing tables, queries, functions, and connecting databases with PHP. The document is organized into 12 labs that progressively build skills with HTML, PHP, SQL, MySQL and PL/SQL.
Similar to Integrating php with embedded system - IOT (20)
This is Eight Channel relay board controlled by Bluetooth Module. The Bluetooth relay board is with 8
SPDT relays rated up to 7A each. You can control devices 230V / 120V (up to 8) directly with one such
relay unit. Suitable for home automation applications, hobby projects, industrial
automation. Bluetooth module enables you to wireless transmit & receive serial data.
4 Channel Relay Board 5V-Bluetooth Compatible for ArduinoRaghav Shetty
Bluetooth technology is a short distance communication technology used by almost all phones
including smart phones and all laptops. This technology find very wide uses including that of Home &
Industrial automation.
The Relay shield is capable of controlling 4 relays. The max switching power could be
12A/250VAC or 15A/24VDC. It could be directly controlled by Arduino through digital IOs.
4 Channel Relay Board 12V-Compatible for ArduinoRaghav Shetty
4 Channel Relay Board 12V-Compatible for Arduino. The Relay shield is capable of controlling 4
relays. The max switching power could be 10A/120VAC or 10A/24VDC. It could be directly controlled by
Arduino through digital IOs. Each relay can switch variety of AC or DC high voltage, high current loads
working at 110V or 220V AC 7Amps mains like lights, fans, motors etc.
This is Eight Channel relay board controlled through RS485 protocol. The RS485 relay
board is with 8 SPDT relays rated up to 7A each. You can control devices 230V / 120V (up to 8)
directly with one such relay unit. Suitable for home automation applications, hobby projects,
industrial automation.
XBee is very easy and popular wireless device. It is a transceiver, it can transmit and it receive
data wirelessly. There are several types of XBee module. The very popular XBee is Series 1
(802.15.4), comes with the firmware to create connection for point to point or star network. But
bear in mind, many people actually thought it is using ZigBee protocol, but it is not compliance
to ZigBee because it uses the low layer of ZigBee protocol only
This basic piezo sensor can be used in anti-theft devices, electronic locks, mechanical equipment vibration detection, sound gesture application and detection range bull's-eye counts vibration sensor occasions. These vibration levels could be given to any controller/processor and necessary decisions could be taken through it. Module triple output mode, digital output simple, analog output more accurate, serial output with exact readings.
Support 5V-9V wide power voltage, Low-noise direct thermal printing method, can support Max.39MM (diameter) paper roll,RS-232C/TTL Interface, rich of graphics / curves / characters print function, Easy paper loading structure, outline dimension : 111W*65D*57H mm.
This document describes a digital soil moisture sensor that can be used to automatically monitor soil moisture levels and trigger watering systems. The sensor outputs a digital signal indicating soil moisture levels and can connect to devices like Arduino. It works by measuring the dielectric constant of soil which corresponds to moisture level. The sensor has adjustable sensitivity and threshold levels and provides digital, analog or serial output of moisture readings for various microcontroller applications.
Micro SD Memory Card Interface for 5V MCURaghav Shetty
This is a wonderful little SD card interface module. It is easily interfaced as a peripheral to your module. Through programming, you can read and write to the SD card. All SD Card works on 3V interface so if your microcontroller is working on 5V you will need to convert these signals.. All SD Card works on 3V interface so if your microcontroller is working on 5V you will need to convert these signals.
Micro SD Memory Card Interface for 3.3V MCURaghav Shetty
This is a wonderful little SD card interface module. It is easily interfaced as a peripheral to your module. Through programming, you can read and write to the SD card.All SD Card works on 3V interface so if your microcontroller is working on 3V you can use this board readily. The interface board provided is for microcontrollers running at 3V.
The regulated power supply accepts unregulated inputs from 9V to 15V AC or DC and gives regulated output of 3.3V, 5V and 12V suitable for projects which needs precise voltage to work. The input can come from step down transformer. Since board has Diode Bridge input polarity does not matter. All outputs are brought to screw terminal. There is also an unregulated output voltage to drive high current loads like relays and motors.
With this board you can develop and prototype with any of Microchip's 40 pin PIC microcontrollers. The RS232 driver on board allows easy connection with PC or other embedded hardware. The bridge rectifier allow this board to be powered with both AC and DC power supply adapters
8 Channel Bi Directional Logic Level ConverterRaghav Shetty
Because the Arduino (and Basic Stamp) are 5V devices, and most modern sensors, displays, flash cards and modes are 3.3V-only, many makers find that they need to perform level shifting/conversion to protect the 3.3V device from 5V.This 8-bit non inverting translator uses two separate configurable power-supply rails. The A port is designed to track VCCA. VCCA accepts any supply voltage from 1.2 V to 3.6 V. The B port is designed to track VCCB. VCCB accepts any supply voltage from 1.65 V to 5.5 V. This allows for universal low-voltage bidirectional translation between any of the 1.2-V, 1.5-V, 1.8-V, 2.5-V, 3.3-V, and 5-V voltage nodes. VCCA should not exceed VCCB.
One of the basic interfacing requirements for the hobbyists or electronics enthusiasts is I/P (keypad) and O/P (LCD display) for prototype applications. This shield uses minimum number I/O’s that is 4 bits for LCD data and 2 control signal lines for the same. A single analog pin (Pin A0) is multiplexed to read 5 input key switches (Navigation keys). Each key has been pulled up to a different voltage level, so a different voltage will be generated every time a user selects a key. This voltage could be read by the analog pin A0 on the board. Hence saves the no of I/O pins. The backlight of the LCD could be controlled by setting PWM (Pin D10) by adding a few lines of code.
The L298 Driver is a high voltage, high current dual ful bridge driver designed to accept standard TTL logic levels and drive inductive loads such relays, solenoids, DC and stepping motors. Two enable inputs are provided to enable or disable the device independently of the input signals. The emitters of the lower transistors of each bridge are connected together the corresponding external terminal can be used for the connection of an external sensing resistor.
The Joystick Shield easily stacks on top of your ATmega 328 and turns it into a simple robotic and gaming controller. Six momentary push buttons (4+2), a two-axis thumb joystick and optional remote transmission adapter for Xbee and Bluetooth allows your ATmega 328 to control from remote location. ATmega 328 digital pins D3-D8 are connected to momentary push buttons, when pressed they will pull the pin HIGH. Voltage accross analog pin 0 varies proportionally for the vertical movement of the joystick, like wise horizontal movement can be tracked at analog pin 1.Xbee Dout is connected to D0(Rx) and Din is connected to D1(Tx) of ATmega 328 sheild.
This is a force sensitive resistor with a round, 0.5" diameter, sensing area. This FSR will vary its resistance depending on how much pressure is being applied to the sensing area. The harder the force, the lower the resistance. When no pressure is being applied to the FSR its resistance will be larger than 1M. This FSR can sense applied force anywhere in the range of 100g-10kg.
Level switch magnetic reed switch and float by the composition of the reed switch encapsulated in the guide rod , fitted with a ring magnet in the float when the float moves up and down with the measured liquid level , its internal magnet to attract magnetic reed switch contact action , thereby detecting the level position as a level control or direction
Flex Sensor 4.2" ROHS Compliant Description: A simple flex sensor 4.2" in length. As the sensor is flexed, the resistance across the sensor increases. The resistance of the flex sensor changes when the metal pads are on the outside of the bend (text on inside of bend). Connector is0.1" spaced and bread board friendly. Note: Please refrain from flexing or straining this sensor at the base. The usable range of the sensor can be flexed without a problem, but care should be taken to minimize flexing outside of the usable range. For best results, securely mount the base and bottom portion and only allow the actual flex sensor to flex.
Climate Impact of Software Testing at Nordic Testing DaysKari Kakkonen
My slides at Nordic Testing Days 6.6.2024
Climate impact / sustainability of software testing discussed on the talk. ICT and testing must carry their part of global responsibility to help with the climat warming. We can minimize the carbon footprint but we can also have a carbon handprint, a positive impact on the climate. Quality characteristics can be added with sustainability, and then measured continuously. Test environments can be used less, and in smaller scale and on demand. Test techniques can be used in optimizing or minimizing number of tests. Test automation can be used to speed up testing.
Sudheer Mechineni, Head of Application Frameworks, Standard Chartered Bank
Discover how Standard Chartered Bank harnessed the power of Neo4j to transform complex data access challenges into a dynamic, scalable graph database solution. This keynote will cover their journey from initial adoption to deploying a fully automated, enterprise-grade causal cluster, highlighting key strategies for modelling organisational changes and ensuring robust disaster recovery. Learn how these innovations have not only enhanced Standard Chartered Bank’s data infrastructure but also positioned them as pioneers in the banking sector’s adoption of graph technology.
Essentials of Automations: The Art of Triggers and Actions in FMESafe Software
In this second installment of our Essentials of Automations webinar series, we’ll explore the landscape of triggers and actions, guiding you through the nuances of authoring and adapting workspaces for seamless automations. Gain an understanding of the full spectrum of triggers and actions available in FME, empowering you to enhance your workspaces for efficient automation.
We’ll kick things off by showcasing the most commonly used event-based triggers, introducing you to various automation workflows like manual triggers, schedules, directory watchers, and more. Plus, see how these elements play out in real scenarios.
Whether you’re tweaking your current setup or building from the ground up, this session will arm you with the tools and insights needed to transform your FME usage into a powerhouse of productivity. Join us to discover effective strategies that simplify complex processes, enhancing your productivity and transforming your data management practices with FME. Let’s turn complexity into clarity and make your workspaces work wonders!
How to Get CNIC Information System with Paksim Ga.pptxdanishmna97
Pakdata Cf is a groundbreaking system designed to streamline and facilitate access to CNIC information. This innovative platform leverages advanced technology to provide users with efficient and secure access to their CNIC details.
Pushing the limits of ePRTC: 100ns holdover for 100 daysAdtran
At WSTS 2024, Alon Stern explored the topic of parametric holdover and explained how recent research findings can be implemented in real-world PNT networks to achieve 100 nanoseconds of accuracy for up to 100 days.
Removing Uninteresting Bytes in Software FuzzingAftab Hussain
Imagine a world where software fuzzing, the process of mutating bytes in test seeds to uncover hidden and erroneous program behaviors, becomes faster and more effective. A lot depends on the initial seeds, which can significantly dictate the trajectory of a fuzzing campaign, particularly in terms of how long it takes to uncover interesting behaviour in your code. We introduce DIAR, a technique designed to speedup fuzzing campaigns by pinpointing and eliminating those uninteresting bytes in the seeds. Picture this: instead of wasting valuable resources on meaningless mutations in large, bloated seeds, DIAR removes the unnecessary bytes, streamlining the entire process.
In this work, we equipped AFL, a popular fuzzer, with DIAR and examined two critical Linux libraries -- Libxml's xmllint, a tool for parsing xml documents, and Binutil's readelf, an essential debugging and security analysis command-line tool used to display detailed information about ELF (Executable and Linkable Format). Our preliminary results show that AFL+DIAR does not only discover new paths more quickly but also achieves higher coverage overall. This work thus showcases how starting with lean and optimized seeds can lead to faster, more comprehensive fuzzing campaigns -- and DIAR helps you find such seeds.
- These are slides of the talk given at IEEE International Conference on Software Testing Verification and Validation Workshop, ICSTW 2022.
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfMalak Abu Hammad
Discover how MongoDB Atlas and vector search technology can revolutionize your application's search capabilities. This comprehensive presentation covers:
* What is Vector Search?
* Importance and benefits of vector search
* Practical use cases across various industries
* Step-by-step implementation guide
* Live demos with code snippets
* Enhancing LLM capabilities with vector search
* Best practices and optimization strategies
Perfect for developers, AI enthusiasts, and tech leaders. Learn how to leverage MongoDB Atlas to deliver highly relevant, context-aware search results, transforming your data retrieval process. Stay ahead in tech innovation and maximize the potential of your applications.
#MongoDB #VectorSearch #AI #SemanticSearch #TechInnovation #DataScience #LLM #MachineLearning #SearchTechnology
UiPath Test Automation using UiPath Test Suite series, part 5DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 5. In this session, we will cover CI/CD with devops.
Topics covered:
CI/CD with in UiPath
End-to-end overview of CI/CD pipeline with Azure devops
Speaker:
Lyndsey Byblow, Test Suite Sales Engineer @ UiPath, Inc.
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!SOFTTECHHUB
As the digital landscape continually evolves, operating systems play a critical role in shaping user experiences and productivity. The launch of Nitrux Linux 3.5.0 marks a significant milestone, offering a robust alternative to traditional systems such as Windows 11. This article delves into the essence of Nitrux Linux 3.5.0, exploring its unique features, advantages, and how it stands as a compelling choice for both casual users and tech enthusiasts.
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Speck&Tech
ABSTRACT: A prima vista, un mattoncino Lego e la backdoor XZ potrebbero avere in comune il fatto di essere entrambi blocchi di costruzione, o dipendenze di progetti creativi e software. La realtà è che un mattoncino Lego e il caso della backdoor XZ hanno molto di più di tutto ciò in comune.
Partecipate alla presentazione per immergervi in una storia di interoperabilità, standard e formati aperti, per poi discutere del ruolo importante che i contributori hanno in una comunità open source sostenibile.
BIO: Sostenitrice del software libero e dei formati standard e aperti. È stata un membro attivo dei progetti Fedora e openSUSE e ha co-fondato l'Associazione LibreItalia dove è stata coinvolta in diversi eventi, migrazioni e formazione relativi a LibreOffice. In precedenza ha lavorato a migrazioni e corsi di formazione su LibreOffice per diverse amministrazioni pubbliche e privati. Da gennaio 2020 lavora in SUSE come Software Release Engineer per Uyuni e SUSE Manager e quando non segue la sua passione per i computer e per Geeko coltiva la sua curiosità per l'astronomia (da cui deriva il suo nickname deneb_alpha).
Driving Business Innovation: Latest Generative AI Advancements & Success StorySafe Software
Are you ready to revolutionize how you handle data? Join us for a webinar where we’ll bring you up to speed with the latest advancements in Generative AI technology and discover how leveraging FME with tools from giants like Google Gemini, Amazon, and Microsoft OpenAI can supercharge your workflow efficiency.
During the hour, we’ll take you through:
Guest Speaker Segment with Hannah Barrington: Dive into the world of dynamic real estate marketing with Hannah, the Marketing Manager at Workspace Group. Hear firsthand how their team generates engaging descriptions for thousands of office units by integrating diverse data sources—from PDF floorplans to web pages—using FME transformers, like OpenAIVisionConnector and AnthropicVisionConnector. This use case will show you how GenAI can streamline content creation for marketing across the board.
Ollama Use Case: Learn how Scenario Specialist Dmitri Bagh has utilized Ollama within FME to input data, create custom models, and enhance security protocols. This segment will include demos to illustrate the full capabilities of FME in AI-driven processes.
Custom AI Models: Discover how to leverage FME to build personalized AI models using your data. Whether it’s populating a model with local data for added security or integrating public AI tools, find out how FME facilitates a versatile and secure approach to AI.
We’ll wrap up with a live Q&A session where you can engage with our experts on your specific use cases, and learn more about optimizing your data workflows with AI.
This webinar is ideal for professionals seeking to harness the power of AI within their data management systems while ensuring high levels of customization and security. Whether you're a novice or an expert, gain actionable insights and strategies to elevate your data processes. Join us to see how FME and AI can revolutionize how you work with data!
Best 20 SEO Techniques To Improve Website Visibility In SERPPixlogix Infotech
Boost your website's visibility with proven SEO techniques! Our latest blog dives into essential strategies to enhance your online presence, increase traffic, and rank higher on search engines. From keyword optimization to quality content creation, learn how to make your site stand out in the crowded digital landscape. Discover actionable tips and expert insights to elevate your SEO game.
Building Production Ready Search Pipelines with Spark and MilvusZilliz
Spark is the widely used ETL tool for processing, indexing and ingesting data to serving stack for search. Milvus is the production-ready open-source vector database. In this talk we will show how to use Spark to process unstructured data to extract vector representations, and push the vectors to Milvus vector database for search serving.
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...Neo4j
Leonard Jayamohan, Partner & Generative AI Lead, Deloitte
This keynote will reveal how Deloitte leverages Neo4j’s graph power for groundbreaking digital twin solutions, achieving a staggering 100x performance boost. Discover the essential role knowledge graphs play in successful generative AI implementations. Plus, get an exclusive look at an innovative Neo4j + Generative AI solution Deloitte is developing in-house.
HCL Notes and Domino License Cost Reduction in the World of DLAUpanagenda
Webinar Recording: https://www.panagenda.com/webinars/hcl-notes-and-domino-license-cost-reduction-in-the-world-of-dlau/
The introduction of DLAU and the CCB & CCX licensing model caused quite a stir in the HCL community. As a Notes and Domino customer, you may have faced challenges with unexpected user counts and license costs. You probably have questions on how this new licensing approach works and how to benefit from it. Most importantly, you likely have budget constraints and want to save money where possible. Don’t worry, we can help with all of this!
We’ll show you how to fix common misconfigurations that cause higher-than-expected user counts, and how to identify accounts which you can deactivate to save money. There are also frequent patterns that can cause unnecessary cost, like using a person document instead of a mail-in for shared mailboxes. We’ll provide examples and solutions for those as well. And naturally we’ll explain the new licensing model.
Join HCL Ambassador Marc Thomas in this webinar with a special guest appearance from Franz Walder. It will give you the tools and know-how to stay on top of what is going on with Domino licensing. You will be able lower your cost through an optimized configuration and keep it low going forward.
These topics will be covered
- Reducing license cost by finding and fixing misconfigurations and superfluous accounts
- How do CCB and CCX licenses really work?
- Understanding the DLAU tool and how to best utilize it
- Tips for common problem areas, like team mailboxes, functional/test users, etc
- Practical examples and best practices to implement right away
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024Neo4j
Neha Bajwa, Vice President of Product Marketing, Neo4j
Join us as we explore breakthrough innovations enabled by interconnected data and AI. Discover firsthand how organizations use relationships in data to uncover contextual insights and solve our most pressing challenges – from optimizing supply chains, detecting fraud, and improving customer experiences to accelerating drug discoveries.
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Integrating php with embedded system - IOT
1. Integrating PHP with Embedded System
www.researchdesignlab.com Page 1
Integrating PHP
with Embedded
System
2. Integrating PHP with Embedded System
www.researchdesignlab.com Page 2
Contents
What is PHP?..........................................................................................................................................6
Basic PHP Syntax.................................................................................................................................6
Hello World example ..........................................................................................................................6
Error Management................................................................................................................................8
Finding errors present in the program ...............................................................................................9
Comments in PHP................................................................................................................................12
PHP is a Loosely Typed Language......................................................................................................12
PHP Variables Example.......................................................................................................................12
Global and locally-scoped variables...................................................................................................13
Example for Global and locally-scoped variables .............................................................................13
Static Keyword in PHP ........................................................................................................................14
Static Keyword Example....................................................................................................................14
ECHO and PRINT statements in PHP .................................................................................................15
PRINT Statement Example in PHP.....................................................................................................15
String Functions in PHP......................................................................................................................16
1. strlen() function ........................................................................................................................16
2. strpos() function........................................................................................................................16
Constant in PHP...................................................................................................................................17
Constant string Example ...................................................................................................................17
PHP Example to calculate the area of the circle...............................................................................17
Arithmetic Operators..........................................................................................................................18
Arithmetic Operators Example .........................................................................................................19
Increment and Decrement Operators................................................................................................20
Increment and Decrement Operators Example................................................................................20
Assignment Operators in PHP............................................................................................................21
Assignment Operators Example........................................................................................................21
String Operators in PHP......................................................................................................................23
String Operators Example.................................................................................................................23
The if Statement in PHP......................................................................................................................24
The if Statement Example.................................................................................................................24
The if…else Statement in PHP ............................................................................................................25
The if…else Statement Example........................................................................................................25
The if…elseif…else Statement in PHP ................................................................................................26
3. Integrating PHP with Embedded System
www.researchdesignlab.com Page 3
The if…elseif…else Statement Example (Comparing two numbers).................................................26
Switch Statement in PHP ....................................................................................................................27
Switch Statement Example ...............................................................................................................27
For loop in PHP....................................................................................................................................28
For loop Example ..............................................................................................................................28
Declaring multiple variables in for loop Example .............................................................................29
While Loop in PHP...............................................................................................................................30
While Loop Example .........................................................................................................................30
Do While loop in PHP..........................................................................................................................31
Do While loop Example.....................................................................................................................31
User Defined Function Example........................................................................................................32
Swap Numbers PHP Example.............................................................................................................33
PHP Functions - Adding parameters..................................................................................................34
PHP Functions - Return values...........................................................................................................35
Break statement ..................................................................................................................................35
Break statement example.................................................................................................................35
Continue statement.............................................................................................................................36
Continue statement example ...........................................................................................................36
PHP Global Variables - Superglobals .................................................................................................36
$GLOBALS..........................................................................................................................................37
Example:............................................................................................................................................37
$_SERVER..........................................................................................................................................38
Example.............................................................................................................................................38
Array in PHP ..........................................................................................................................................39
Numeric Array in PHP .......................................................................................................................39
Numeric Array Example ....................................................................................................................39
Associative array in PHP........................................................................................................................40
Associative array Example ................................................................................................................40
Loop through an Associative Array.......................................................................................................41
Multidimensional array in PHP .............................................................................................................42
Multidimensional array Example......................................................................................................42
PHP Forms.............................................................................................................................................43
The $_GET Function..........................................................................................................................43
4. Integrating PHP with Embedded System
www.researchdesignlab.com Page 4
The $_POST Function........................................................................................................................43
The $_GET Function Example ...........................................................................................................44
The $_ POST Function Example ........................................................................................................46
Another Example for PHP form.........................................................................................................48
Date() and time() function in PHP.........................................................................................................51
Example.............................................................................................................................................51
How to connect to MYSQL database using PHP ...................................................................................52
The functions used to connect web form to the MYSQL database:.....................................................60
Display the data from MYSQL database in web form...........................................................................61
Insert the data into MYSQL database using web form.........................................................................63
Update the data present in MYSQL database using web form.............................................................66
Delete the data from MYSQL database using web form ......................................................................70
Hosting your domain using cPanel........................................................................................................74
EMBEDDED SYSTEM WITH PHP ............................................................................................................86
OVERVIEW.........................................................................................................................................86
FEATURES..........................................................................................................................................86
APPLICATION DIAGRAM....................................................................................................................86
CIRCUIT DIAGRAM ............................................................................................................................87
PIN CONNECTION..............................................................................................................................88
INTERFACE.........................................................................................................................................89
LIBRARY.............................................................................................................................................89
CODE .................................................................................................................................................90
With Arduino.............................................................................................................................90
1. ADD hello world example from Examples ................................................................................90
2. Add Server Reading Example....................................................................................................90
3. relay interface(Web Remote) ...................................................................................................91
..............................................................................................................................................................91
code:..................................................................................................................................................91
PIN CONNECTION..............................................................................................................................95
WITH ETHERNET MODULE................................................................................................................95
WITH RELAY.......................................................................................................................................96
CODE .................................................................................................................................................98
PHP CODE:.......................................................................................................................................102
5. Integrating PHP with Embedded System
www.researchdesignlab.com Page 5
PIN CONNECTION............................................................................................................................106
code.................................................................................................................................................107
6. Integrating PHP with Embedded System
www.researchdesignlab.com Page 6
What is PHP?
PHP stands for PHP: Hypertext Preprocessor
PHP is a server-side scripting language
PHP scripts are executed on the server
PHP supports many databases (MySQL, Informix, Oracle, Sybase, Solid,
PostgreSQL, Generic ODBC, etc.)
PHP is an open source software
PHP is free to download and use
Basic PHP Syntax
A PHP script starts with <?php and ends with ?>
The default file extension for PHP files is ".php"
A PHP file normally contains HTML tags, and some PHP scripting code
PHP statements are terminated by semicolon (;)
In PHP, all user-defined functions, classes, and keywords (e.g. if, else,
while, echo, etc.) are not case-sensitive
Hello World example
<html>
<body>
<?php
// Use echo to print on console
echo ‚Hello World!‛;
?>
</body>
</html>
Go to htdocs folder which is present in the apache2triad installed folder. There
create a folder and save this program with .php extension such as Hello.php.
7. Integrating PHP with Embedded System
www.researchdesignlab.com Page 7
To execute hello world program, type in the address bar as follows:
http://localhost/MyPHPProgram/hello.php
C:apache2triadhtdocsMyPHPProgram
http://localhost/MyPHPProgram/hello.php
8. Integrating PHP with Embedded System
www.researchdesignlab.com Page 8
Error Management
1. Compile-time errors:
Compile-time errors are detected by the parser while it is compiling a
script.
The compile-time errors cannot be trapped from within the script itself
2. Fatal errors:
Fatal errors are the errors that halt the execution of a script.
The fatal errors cannot be trapped.
3. Recoverable errors:
Recoverable errors that represent significant failures, but can still be
handled in a safe way.
4. Warnings:
Warnings are recoverable errors that indicate a run-time fault.
Warnings do not halt the execution of the script.
5. Notices:
Notices indicate that an error condition occurred, but is not necessarily
significant.
Notices do not halt the execution of the script.
9. Integrating PHP with Embedded System
www.researchdesignlab.com Page 9
Finding errors present in the program
<html>
<body>
<?php
echo ‚Hello World!‛;
// here ? is missing
>
</body>
</html>
To find the errors present in the program go to:
Start -> All programs -> Apache2triad -> Apache2TriadCP
Apache2TriadCP
10. Integrating PHP with Embedded System
www.researchdesignlab.com Page 10
Then click on “PHP Error log”
PHP Error log
11. Integrating PHP with Embedded System
www.researchdesignlab.com Page 11
The list of errors in the program is displayed along with the line number where
the error has occurred.
[05-Jan-2007 05:21:11] PHP Parse error: syntax error, unexpected T_STRING,
expecting ',' or ';' in C:apache2triadhtdocsMyPHPProgramhello.php on line 4
12. Integrating PHP with Embedded System
www.researchdesignlab.com Page 12
Comments in PHP
// Single line comment (C++ and Java-style comment)
# Single line comment (Shell-style comments)
/* Multiple line comment
(C-style comments) */
PHP is a Loosely Typed Language
In PHP, a variable does not need to be declared before adding a value to it
PHP automatically converts the variable to the correct data type,
depending on its value
In PHP, the variable is declared automatically when you use it
PHP variables must begin with a “$” sign
Variables are used for storing values, like text strings, numbers or arrays
The correct way of declaring a variable in PHP:
$var_name = value;
PHP Variables Example
<html>
<body>
<?php
$a = 25; // Numerical variable
$b = ‚Hello‛; // String variable
$c = 5.7; // Float variable
echo ‚Number is : ‛.$a.‚<br/>‛;
echo ‚String is : ‛.$b.‚<br/>‛;
echo ‚Float value : ‛.$c;
?>
</body>
<html>
OUTPUT of the above given Example is as follows:
Number is : 25
String is : Hello
Float value : 5.7
13. Integrating PHP with Embedded System
www.researchdesignlab.com Page 13
Global and locally-scoped variables
Global variables can be used anywhere
Local variables restricted to a function or class
Example for Global and locally-scoped variables
<html>
<body>
<?php
$x=24; // global scope
// Function definition
function myFunction() {
$y=59; // local scope
echo "Variable x is: $x <br>";
echo "Variable y is: $y";
}
myFunction();// Function call
echo "Variable x is: $x";
echo "<br>";
echo "Variable y is: $y";
?>
</body>
</html>
OUTPUT of the above given Example is as follows:
Variable x is:
Variable y is: 59
Test variables outside the function:
Variable x is: 24
Variable y is:
14. Integrating PHP with Embedded System
www.researchdesignlab.com Page 14
Static Keyword in PHP
Static keyword is used when you first declare the variable
Each time the function is called, that variable will still have the information
it contained from the last time the function was called
Static Keyword Example
<html>
<body>
<?php
// Function definition
function myFunction() {
static $x=45;
echo $x;
echo "<br/>";
$x++;
}
// Function call
myFunction();
myFunction();
myFunction();
myFunction();
myFunction();
?>
<body>
<html>
OUTPUT of the above given Example is as follows:
45
46
47
48
49
15. Integrating PHP with Embedded System
www.researchdesignlab.com Page 15
ECHO and PRINT statements in PHP
ECHO - It can output one or more strings
PRINT – It can only output one string, and returns always 1
ECHO is faster compared to PRINT as echo does not return any value
ECHO is not a function and, as such, it does not have a return value
If you need to output data through a function, you can use PRINT() instead:
Example:
echo 50;
print (50);
PRINT Statement Example in PHP
<html>
<body>
<?php
// Use ‘print’ to print on console
print "Hello world!<br>***********";
?>
</body>
</html>
OUTPUT of the above given Example is as follows:
Hello world!
***********
16. Integrating PHP with Embedded System
www.researchdesignlab.com Page 16
String Functions in PHP
strlen() function
strpos() function
1. strlen() function
The strlen() function returns the length of a string, in characters
<html>
<body>
<?php
// Displays the length of the string
echo strlen("Hello world!");
?>
</body>
</html>
OUTPUT of the above given Example is as follows:
12
2. strpos() function
The strpos() function is used to search for a specified character or text
within a string
<html>
<body>
<?php
/* Displays the position of ‘world’ in the
text ‘Hello world*/
echo strpos("Hello world!","world");
?>
</body>
</html>
OUTPUT of the above given Example is as follows:
6
17. Integrating PHP with Embedded System
www.researchdesignlab.com Page 17
Constant in PHP
define() function is used to set a constant
It takes three parameters they are:
1. Name of the constant
2. Value of the constant
3. Third parameter is optional. It specifies whether the constant name
should be case-insensitive. Default is false
Constant string Example
<html>
<body>
<?php
/* Here constant name is ‘Hai’ and ‘Hello
Friend’ is its constant value and true
indicates the constant value is case-
insensitive */
define("Hai","Hello Friend",true);
echo hai;
?>
</body>
</html>
OUTPUT of the above given Example is as follows:
Hello Friend
PHP Example to calculate the area of the circle
<html>
<body>
<?php
// defining constant value PI = 3.14
define("PI","3.14");
$radius=15;
$area=PI*$radius*$radius;
echo "Area=".$area;
?>
</body>
</html>
OUTPUT of the above given Example is as follows:
Area=706.5
19. Integrating PHP with Embedded System
www.researchdesignlab.com Page 19
Arithmetic Operators Example
<html>
<body>
<?php
// Add 20, 10 and sum is stored in $i
$i=(20 + 10);
// Subtract $i, 5 and difference is stored in $j
$j=($i - 5);
// Multiply $j, 4 and result is stored in $k
$k=($j * 4);
// Divide $k, 2 and result is stored in $l
$l=($k / 2);
// Devide $l, 5 and remainder is stored in $m
$m=($l % 5);
echo "i = ".$i."<br/>";
echo "j = ".$j."<br/>";
echo "k = ".$k."<br/>";
echo "l = ".$l."<br/>";
echo "m = ".$m."<br/>";
?>
</body>
</html>
OUTPUT of the above given Example is as follows:
i = 30
j = 25
k = 100
l = 50
m = 0
20. Integrating PHP with Embedded System
www.researchdesignlab.com Page 20
Increment and Decrement Operators
Operator Name Description
++$a Pre-increment Increments $a by one, then returns $a
$a++ Post-increment Returns $a, then increments $a by one
--$a Pre-decrement Decrements $a by one, then returns $a
$a-- Post-decrement Returns $a, then decrements $a by one
Increment and Decrement Operators Example
<html>
<body>
<?php
$i=10;
$j=20;
$i++;
$j++;
echo $i."<br/>";
echo $j."<br/>";
// Post increment
$k=$i++;
// Pre increment
$l=++$j;
echo $k."<br/>";
echo $l;
?>
</body>
</html>
OUTPUT of the above given Example is as follows:
11
21
11
22
21. Integrating PHP with Embedded System
www.researchdesignlab.com Page 21
Assignment Operators in PHP
Assignment operator is used to write a value to a variable
Operator Example Is the same as
= x=y x=y
+= x+=y x=x+y
-= x-=y x=x-y
*= x*=y x=x*y
/= x/=y x=x/y
.= x.=y x=x.y
%= x%=y x=x%y
Assignment Operators Example
<html>
<body>
<?php
$a=5;
echo "a=".$a;
echo "<br/>";
$b=10;
$b += 20;
echo "b=".$b;
echo "<br/>";
$c=15;
$c -= 5;
echo "c=".$c;
echo "<br/>";
$d=20;
$d *= 2;
echo "d=".$d;
echo "<br/>";
22. Integrating PHP with Embedded System
www.researchdesignlab.com Page 22
$e=25;
$e /= 5;
echo "e=".$e;
echo "<br/>";
$f=30;
$f %= 4;
echo "f=".$f;
?>
</body>
</html>
OUTPUT of the above given Example is as follows:
a=5
b=30
c=10
d=40
e=5
f=2
23. Integrating PHP with Embedded System
www.researchdesignlab.com Page 23
String Operators in PHP
Operator Name Example Result
. Concatenation
$a = "Hello"
$b = $a . " world!"
$b = "Hello world!"
.=
Concatenation
Assignment
$a = "Hello"
$a .= " world!"
$a = "Hello world!"
String Operators Example
<html>
<body>
<?php
$a = "Hello";
$b = $a . " Friend!";
echo $b;
echo "<br/>";
$c="Good";
$c .= " Day!";
echo $c;
?>
</body>
</html>
OUTPUT of the above given Example is as follows:
Hello Friend!
Good Day!
24. Integrating PHP with Embedded System
www.researchdesignlab.com Page 24
The if Statement in PHP
If statement executes some code only if a specified condition is true
Syntax:
if (condition) {
code to be executed if condition is true;
}
The if Statement Example
<html>
<body>
<?php
$i=0;
/* If condition is true, statement is
executed*/
if($i==0)
echo "i is 0";
?>
<body>
</html>
OUTPUT of the above given Example is as follows:
i is 0
25. Integrating PHP with Embedded System
www.researchdesignlab.com Page 25
The if…else Statement in PHP
If…else statement executes some code if a condition is true and some
another code if the condition is false
Syntax:
if (condition) {
code to be executed if condition is true;
}
else {
code to be executed if condition is false;
}
The if…else Statement Example
<html>
<body>
<?php
$i=1;
/* If condition is true, statement1 is
executed, else statement2 is executed*/
if($i==0)
echo "i is 0"; //statement1
else
echo "i is not 0"; //statement2
?>
<body>
</html>
OUTPUT of the above given Example is as follows:
i is not 0
26. Integrating PHP with Embedded System
www.researchdesignlab.com Page 26
The if…elseif…else Statement in PHP
If…elseif…else statement selects one of several blocks of code to be
executed
Syntax:
if (condition) {
code to be executed if condition is true;
}
elseif (condition) {
code to be executed if condition is true;
}
else {
code to be executed if condition is false;
}
The if…elseif…else Statement Example (Comparing two numbers)
<html>
<body>
<?php
$i=22;
$j=22;
/* If condition1 is true, statement1 is executed,
if condition1 is false and condition2 is true,
statement2 is executed, if both the conditions
are false statement3 is executed */
if($i>$j)
echo "i is greater"; //statement1
elseif($i<$j)
echo "j is greater"; //statement2
else
echo "numbers are equal"; //Statement3
?>
<body>
</html>
OUTPUT of the above given Example is as follows:
numbers are equal
27. Integrating PHP with Embedded System
www.researchdesignlab.com Page 27
Switch Statement in PHP
Switch statement selects one from multiple blocks of code to be executed
Syntax:
switch (n) {
case label1:
code to be executed if n=label1;
break;
case label2:
code to be executed if n=label2;
break;
...
default:
code to be executed if n is different from all labels;
}
Switch Statement Example
<html>
<body>
<?php
$x=3;
/* Expression value is compared with each case
value. If it matches, statements following
case would be executed. Break statement is
used to terminate the execution of
statement.*/
switch ($x)
{
case 1:
echo "Number 1";
break;
case 2:
echo "Number 2";
break;
case 3:
echo "Number 3";
break;
default:
echo "No number between 1 and 3";
}
?>
</body>
</html>
28. Integrating PHP with Embedded System
www.researchdesignlab.com Page 28
OUTPUT of the above given Example is as follows:
Number 3
For loop in PHP
PHP for loop executes a block of code, a specified number of times
Syntax:
for (initialization; test condition; increment/decrement) {
code to be executed;
}
For loop Example
<html>
<body>
<?php
echo "Numbers from 1 to 20 are: <br>";
/*in for loop, initialization usually declares
a loop variable, condition is a Boolean
expression such that if the condition is true,
loop body will be executed and after each
iteration of loop body, expression is executed
which usually increase or decrease loop
variable*/
for ($x=0; $x<=20; $x++) {
echo "$x ";
}
?>
</body>
</html>
OUTPUT of the above given Example is as follows:
Numbers from 1 to 20 are:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
29. Integrating PHP with Embedded System
www.researchdesignlab.com Page 29
Declaring multiple variables in for loop Example
<html>
<body>
<?php
/* Multiple variables can be declared in
declaration block of for loop */
for ($x=0,$y=1,$z=2;$x<=3;$x++) {
echo "x = $x, y = $y, z = $z <br>";
}
?>
</body>
</html>
OUTPUT of the above given Example is as follows:
x = 0, y = 1, z = 2
x = 1, y = 1, z = 2
x = 2, y = 1, z = 2
x = 3, y = 1, z = 2
30. Integrating PHP with Embedded System
www.researchdesignlab.com Page 30
While Loop in PHP
While loop, loops through a block of code as long as the specified condition
is true
Syntax:
while (condition) {
code to be executed;
}
While Loop Example
<html>
<body>
<?php
$i=1;
/* here <condition> is a Boolean expression.
Loop body is executed as long as condition is
true*/
while($i<5){
echo "i is = $i <br>";
$i++;
}
?>
</body>
</html>
OUTPUT of the above given Example is as follows:
i is = 1
i is = 2
i is = 3
i is = 4
31. Integrating PHP with Embedded System
www.researchdesignlab.com Page 31
Do While loop in PHP
Do while loop will always execute the block of code once, it will then check
the condition, and if the condition is true then it repeats the loop
Syntax:
do {
code to be executed;
} while (condition );
Do While loop Example
<html>
<body>
<?php
$i=1;
/* here <condition> is a Boolean expression. Please
note that the condition is evaluated after executing
the loop body. So loop will be executed at least
once even if the condition is false*/
do
{
echo "i is = $i <br>";
$i++;
}while($i<5);
?>
</body>
</html>
OUTPUT of the above given Example is as follows:
i is = 1
i is = 2
i is = 3
i is = 4
32. Integrating PHP with Embedded System
www.researchdesignlab.com Page 32
User Defined Function in PHP
Functions are group of statements that can perform a task
Syntax:
function functionName() {
code to be executed;
}
User Defined Function Example
<html>
<body>
<?php
// Function definition
function myFunction()
{
echo "Hello world";
}
// Function call
myFunction();
?>
</body>
</html>
OUTPUT of the above given Example is as follows:
Hello world
33. Integrating PHP with Embedded System
www.researchdesignlab.com Page 33
Swap Numbers PHP Example
<html>
<body>
<?php
$num1=10;
$num2=20;
echo "Numbers before swapping:<br/>";
echo "Num1=".$num1;
echo "<br/>Num2=".$num2;
// Function call
swap($num1,$num2);
// Function definition
function swap($n1,$n2)
{
$temp=$n1;
$n1=$n2;
$n2=$temp;
echo "<br/><br/>Numbers after
swapping:<br/>";
echo "Num1=".$n1;
echo "<br/>Num2=".$n2;
}
?>
</body>
</html>
OUTPUT of the above given Example is as follows:
Numbers before swapping:
Num1=10
Num2=20
Numbers after swapping:
Num1=20
Num2=10
34. Integrating PHP with Embedded System
www.researchdesignlab.com Page 34
PHP Functions - Adding parameters
<html>
<body>
<?php
// Function definition
function writeName($fname)
{
echo $fname . " Refsnes.<br />";
}
echo "My name is ";
writeName("Kai Jim"); //Function call
echo "My sister's name is ";
writeName("Hege"); // Function call
echo "My brother's name is ";
writeName("Stale"); // Function call
?>
</body>
</html>
OUTPUT of the above given Example is as follows:
My name is Kai Jim Refsnes.
My sister's name is Hege Refsnes.
My brother's name is Stale Refsnes.
35. Integrating PHP with Embedded System
www.researchdesignlab.com Page 35
PHP Functions - Return values
<html>
<body>
<?php
// Function definition
function add($x,$y)
{
$total=$x+$y;
return $total;
}
// Function call
echo "1 + 16 = " . add(1,16);
?>
</body>
</html>
OUTPUT of the above given Example is as follows:
1 + 16 = 17
Break statement
Break statement is used to terminate the loop
After the break statement is executed the control goes to the statement
immediately after the loop containing break statement
Break statement example
<html>
<body>
<?php
/* when $i value becomes 3, the loop is
Terminated*/
for($i=0;$i<5;$i++)
{
if($i==3)
break;
else
echo "$i ";
}
?>
</body>
</html>
OUTPUT of the above given Example is as follows:
0 1 2
36. Integrating PHP with Embedded System
www.researchdesignlab.com Page 36
Continue statement
There are cases in which, rather than terminating a loop, you simply want
to skip over the remainder of iteration and immediately skip over to the
next. Continue statement is used to skip a particular iteration of the loop.
Continue statement example
<html>
<body>
<?php
/* when $i value becomes 3, it will skip the
particular of the loop*/
for($i=0;$i<=5;$i++)
{
if($i==3)
continue;
else
echo "$i ";
}
?>
</body>
</html>
OUTPUT of the above given Example is as follows:
0 1 2 4 5
PHP Global Variables - Superglobals
"Superglobals" are predefined variables in PHP
They are always accessible, regardless of scope - and can access them from
any function, class or file
The PHP superglobal variables are:
$GLOBALS
$_SERVER
$_REQUEST
$_POST
$_GET
$_FILES
$_ENV
$_COOKIE
$_SESSION
37. Integrating PHP with Embedded System
www.researchdesignlab.com Page 37
$GLOBALS
$GLOBALS is a PHP super global variable which is used to access global
variables from anywhere in the PHP script (also from within functions or
methods)
PHP stores all global variables in an array called $GLOBALS[index]. The
index holds the name of the variable
Example:
<html>
<body>
<?php
$a = 20;
$b = 40;
function addition()
{
$GLOBALS['c'] = $GLOBALS['a'] + $GLOBALS['b'];
}
addition();
echo $c;
?>
</body>
</html>
OUTPUT of the above given Example is as follows:
60
38. Integrating PHP with Embedded System
www.researchdesignlab.com Page 38
$_SERVER
$_SERVER is a PHP super global variable which holds information about
headers, paths, and script locations
Example
<html>
<body>
<?php
echo $_SERVER['PHP_SELF'];
echo "<br>";
echo $_SERVER['SERVER_NAME'];
echo "<br>";
echo $_SERVER['HTTP_HOST'];
echo "<br>";
echo $_SERVER['HTTP_USER_AGENT'];
echo "<br>";
echo $_SERVER['SCRIPT_NAME'];
?>
</body>
</html>
OUTPUT of the above given Example is as follows:
/User/server.php
localhost
localhost
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; GTB7.5; SLCC2;
.NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC
6.0; InfoPath.2; .NET CLR 1.1.4322)
/User/server.php
39. Integrating PHP with Embedded System
www.researchdesignlab.com Page 39
Array in PHP
An array stores multiple values in one single variable
In PHP, there are three kinds of arrays:
Numeric array
Associative array
Multidimensional array
Numeric Array in PHP
Numeric array is an array with a numeric index
Numeric Array Example
<html>
<body>
<?php
/* An array $flower_shop is created with three
Values - rose, daisy,orchid */
$flower_shop = array (
"rose",
"daisy",
"orchid"
);
/* Values of array $flower_shop is displayed based
on index. The starting index of an array is Zero */
echo "Flowers: ".$flower_shop[0].",
".$flower_shop[1].", ".$flower_shop[2]."";
?>
</body>
</html>
OUTPUT of the above given Example is as follows:
Flowers: rose, daisy, orchid
40. Integrating PHP with Embedded System
www.researchdesignlab.com Page 40
Associative array in PHP
Associative array is an array where each ID key is associated with a value
Associative array Example
<html>
<body>
<?php
/* Here rose, daisy and orchid indicates ID key and
5.00, 4.00, 2.00 indicates their values respectively
*/
$flower_shop = array (
"rose" => "5.00",
"daisy" => "4.00",
"orchid" => "2.00"
);
// Display the array values
echo "rose costs
.$flower_shop['rose'].",daisy costs
".$flower_shop['daisy'].",and orchild
costs ".$flower_shop['orchild']."";
?>
</body>
</html>
OUTPUT of the above given Example is as follows:
rose costs 5.00,daisy costs 4.00,and orchild costs
41. Integrating PHP with Embedded System
www.researchdesignlab.com Page 41
Loop through an Associative Array
<html>
<body>
<?php
$flower_shop=array("rose"=>"5.00",
"daisy"=>"4.00","orchid"=>"2.00");
/* for each loop works only on arrays, and is used
to loop through each key/value pair in an array */
foreach($flower_shop as $x=>$x_value) {
echo "Flower=" . $x .
", Value=" . $x_value;
echo "<br>";
}
?>
</body>
</html>
OUTPUT of the above given Example is as follows:
Flower=rose, Value=5.00
Flower=daisy, Value=4.00
Flower=orchid, Value=2.00
42. Integrating PHP with Embedded System
www.researchdesignlab.com Page 42
Multidimensional array in PHP
Multidimensional array is an array containing one or more arrays
Multidimensional array Example
<html>
<body>
<?php
/* Here $flower_shop is an array, where rose, daisy and orchid
are the ID key which indicates rows and points to array which
have column values. */
$flower_shop = array(
"rose" => array( "5.00", "7 items", "red" ),
"daisy" => array( "4.00", "3 items", "blue" ),
"orchid" => array( "2.00", "1 item", "white" ),
);
/* in the array $flower_shop['rose'][0], ‘rose’ indicates row
and ‘0’ indicates column */
echo "rose costs ".$flower_shop['rose'][0].
", and you get ".$flower_shop['rose'][1].".<br>";
echo "daisy costs ".$flower_shop['daisy'][0].
", and you get ".$flower_shop['daisy'][1].".<br>";
echo "orchid costs ".$flower_shop['orchid'][0].
", and you get ".$flower_shop['orchid'][1].".<br>";
?>
</body>
</html>
OUTPUT of the above given Example is as follows:
rose costs 5.00, and you get 7 items.
daisy costs 4.00, and you get 3 items.
orchid costs 2.00, and you get 1 item.
43. Integrating PHP with Embedded System
www.researchdesignlab.com Page 43
PHP Forms
Scripts will interact with their clients using one of the two HTTP methods.
The methods are GET and POST
When a form is submitted using the GET method, its values are encoded
directly in the query string portion of the URL
When a form is submitted using the POST method, its values will not be
displayed the query string portion of the URL
The $_GET Function
The built-in $_GET function is used to collect values from a form sent with
method="get"
Information sent from a form with the GET method is visible to everyone
(it will be displayed in the browser's URL) and has limits on the amount of
information to send (max. 100 characters)
This method should not be used when sending passwords or other
sensitive information. However, because the variables are displayed in the
URL, it is possible to bookmark the page
The get method is not suitable for large variable values; the value cannot
exceed 100 characters
The $_POST Function
The built-in $_POST function is used to collect values from a form sent with
method="post"
Information sent from a form with the POST method is invisible to others
and has no limits on the amount of information to send
However, there is an 8 Mb max size for the POST method, by default (can
be changed by setting the post_max_size in the php.ini file)
44. Integrating PHP with Embedded System
www.researchdesignlab.com Page 44
The $_GET Function Example
Form1.html
<html>
<body>
/* form submitted using ‘get’ method, action specifies
next page which is to be loaded when button is clicked*/
<form action="welcome.php" method="get">
// textbox is to take user input
Name: <input type="text" name="fname" />
Age: <input type="text" name="age" />
// Submit button is to submit the value
<input type="submit" />
</form>
</body>
</html>
welcome.php
<html>
<body>
// $_GET to receive the data sent from Form1.html
Welcome <?php echo $_GET["fname"]; ?>.<br />
You are <?php echo $_GET["age"]; ?> years old!
</body>
</html>
45. Integrating PHP with Embedded System
www.researchdesignlab.com Page 45
OUTPUT of the above given Example is as follows:
In this example, when you click on the “submit” button, the values entered in the
textbox are encoded directly in the query string portion of the URL.
46. Integrating PHP with Embedded System
www.researchdesignlab.com Page 46
The $_ POST Function Example
form1.html
<html>
<body>
/* form submitted using ‘post’ method, action specifies
next page which is to be loaded when button is clicked */
<form action="welcome1.php" method="post">
// textbox is to take user input
Name: <input type="text" name="fname" />
Age: <input type="text" name="age" />
// Submit button is to submit the value to next page
<input type="submit" />
</form>
</body>
</html>
welcome1.php
<html>
<body>
// $_GET to receive the data sent from form1.html
Welcome <?php echo $_POST["fname"]; ?>.<br />
You are <?php echo $_POST["age"]; ?> years old!
</body>
</html>
47. Integrating PHP with Embedded System
www.researchdesignlab.com Page 47
OUTPUT of the above given Example is as follows:
In this example, when you click on the “submit” button, the values will not be
displayed the query string portion of the URL.
48. Integrating PHP with Embedded System
www.researchdesignlab.com Page 48
Another Example for PHP form
Form.html
<html>
<head>
<title>Process the HTML form data with the POST
method</title>
</head>
<body>
/* form submitted using ‘post’ method, action specifies next page
which is to be loaded when button is clicked */
<form name="myform" action="process.php" method="POST">
// create an hidden textbox
<input type="hidden" name="check_submit" value="1" />
// textbox is to take user input
Name: <input type="text" name="Name" /><br />
Password: <input type="password" name="Password"
maxlength="10" /><br />
// Use ‘select’ tag to display the various options
Select something from the list: <select name="Seasons">
<option value="Spring"
selected="selected">Spring</option>
<option value="Summer">Summer</option>
<option value="Autumn">Autumn</option>
<option value="Winter">Winter</option>
</select><br /><br />
Choose one:
//This will create radio buttons
<input type="radio" name="Country" value="USA" /> USA
<input type="radio" name="Country" value="Canada" />
Canada
<input type="radio" name="Country" value="Other" />
Other
<br />
Choose the colors:
//This will create checkbox
<input type="checkbox" name="Colors[]" value="green"
checked="checked" /> Green
<input type="checkbox" name="Colors[]" value="yellow"
/> Yellow
<input type="checkbox" name="Colors[]" value="red" />
Red
49. Integrating PHP with Embedded System
www.researchdesignlab.com Page 49
<input type="checkbox" name="Colors[]" value="gray" />
Gray
<br />
// Submit button is to submit the value to next page
<input type="submit" />
</form>
</body>
</html>
Process.php
<html>
<body>
<?php
if (array_key_exists('check_submit', $_POST)) {
/*Converts the new line characters (n) in the text
area into HTML line breaks (the <br /> tag) */
$_POST['Comments'] = nl2br($_POST['Comments']);
//Check whether a $_GET['Languages'] is set
if ( isset($_POST['Colors']) ) {
$_POST['Colors'] = implode(', ', $_POST['Colors']);
//Converts an array into a single string
}
//Let's now print out the received values in the browser
echo "Your name: {$_POST['Name']}<br />";
echo "Your password: {$_POST['Password']}<br />";
echo "Your favourite season: {$_POST['Seasons']}
<br/><br />";
echo "You are from: {$_POST['Country']}<br />";
echo "Colors you chose: {$_POST['Colors']}<br />";
}
else
{
echo "You can't see this page without submitting the
form.";
}
?>
</body>
</html>
50. Integrating PHP with Embedded System
www.researchdesignlab.com Page 50
OUTPUT of the above given Example is as follows:
51. Integrating PHP with Embedded System
www.researchdesignlab.com Page 51
Date() and time() function in PHP
The PHP date() function formats a timestamp to a more readable date and
time
A timestamp is a sequence of characters, denoting the date and/or time at
which a certain event occurred
Some characters that are commonly used for date and time:
d - Represents the day of the month (01 to 31)
m - Represents a month (01 to 12)
Y - Represents a year (in four digits)
l (lowercase 'L') - Represents the day of the week
h - 12-hour format of an hour with leading zeros (01 to 12)
i - Minutes with leading zeros (00 to 59)
s - Seconds with leading zeros (00 to 59)
a - Lowercase Ante meridiem and Post meridiem (am or pm)
Example
<html>
<body>
<?php
// display the date in the format YYYY/MM/DD
echo "Today is " . date("Y/m/d") . "<br>";
// ‘l’ is used to display the day
echo "Today is " . date("l"). "<br>";
// display the time in the format HH:MM:SS
echo "The time is " . date("h:i:sa");
?>
</body>
</html>
OUTPUT of the above given Example is as follows:
Today is 2014/08/19
Today is Tuesday
The time is 09:13:22am
52. Integrating PHP with Embedded System
www.researchdesignlab.com Page 52
How to connect to MYSQL database using
PHP
To connect MYSQL using PHP go to: http://localhost//phpmyadmin
Enter the username and password
Give the database name in the field ‘create new database’
Click on create button
53. Integrating PHP with Embedded System
www.researchdesignlab.com Page 53
Create a new table in the database by giving a table name and number of fields
then click on Go
54. Integrating PHP with Embedded System
www.researchdesignlab.com Page 54
To give field name to the created table, write the field name in the ‘field’ column,
select the data types for each fields, specify the length of each field then click on
save to save the fields and click on Go
55. Integrating PHP with Embedded System
www.researchdesignlab.com Page 55
When clicked on Go the table field details will be displayed
56. Integrating PHP with Embedded System
www.researchdesignlab.com Page 56
To insert values in the field, go to insert and enter the values. Then click on Go
To view the created table, go to browse
57. Integrating PHP with Embedded System
www.researchdesignlab.com Page 57
To insert the values, go to SQL and write the query to insert the values and click
on Go
SQL query for insert:
Syntax:
Insert into table_name values(‘value1’,’value2’,…);
Example:
Insert into Login values(‘Radha’,’hello’);
58. Integrating PHP with Embedded System
www.researchdesignlab.com Page 58
To update the values, go to SQL and write the query to update the values and
click on Go
SQL query for update:
Syntax:
Update table_name set field_name=’value’ where field_name=’value’;
Example:
Update Login set password=’abcde’ where name=’Radha’;
59. Integrating PHP with Embedded System
www.researchdesignlab.com Page 59
To delete the values, go to SQL and write the query to delete the values and click
on go
SQL query for delete:
Syntax:
Delete from table_name where field_name=’value’;
Example:
Delete from Login where name=’Radha’;
60. Integrating PHP with Embedded System
www.researchdesignlab.com Page 60
The functions used to connect web form to
the MYSQL database:
mysql_connect():
This function opens a link to a MySQL server on the specified host (in this
case it's localhost) along with a username (root) and password (q1w2e3r4/). The
result of the connection is stored in the variable $db.
mysql_select_db():
This tells PHP that any queries we make are against the mydb database.
mysql_query():
Using the database connection identifier, it sends a line of SQL to the
MySQL server to be processed. The results that are returned are stored in the
variable $result.
mysql_result():
This is used to display the values of fields from our query. Using $result,
we go to the first row, which is numbered 0, and display the value of the specified
fields.
mysql_result($result,0,"position")):
This should be treated as a string and printed.
61. Integrating PHP with Embedded System
www.researchdesignlab.com Page 61
Display the data from MYSQL database in
web form
<html>
<body>
<?php
// Open MYSQL server connection
$db = mysql_connect("localhost", "root","q1w2e3r4/");
// Select the database using MYSQL server connection
mysql_select_db("mydb",$db);
/* Using the database connection identifier, it sends
a line of SQL to the MySQL server to be processed
and the results are stored in the variable
$result. */
$result = mysql_query("SELECT * FROM employees",$db);
// Displaying the details in a table
echo "<table border=1>";
echo "<tr><th>Name</th><th>Position</th></tr>";
while ($myrow = mysql_fetch_row($result)) {
printf("<tr><td>%s %s</td><td>%s</td></tr>",
$myrow[1], $myrow[2],$myrow[4]);
}
echo "</table>";
?>
</body>
</html>
62. Integrating PHP with Embedded System
www.researchdesignlab.com Page 62
OUTPUT of the above given Example would be:
63. Integrating PHP with Embedded System
www.researchdesignlab.com Page 63
Insert the data into MYSQL database using
web form
<html>
<body>
<?php
if ($submit) {
// Open MYSQL server connection
$db = mysql_connect("localhost", "root","q1w2e3r4/");
// Select the database using MYSQL server connection
mysql_select_db("mydb",$db);
/* Write insert query and assign the query in $sql
Variable */
$sql = "INSERT INTO employees (first,last,address,position)
VALUES('$first','$last','$address','$position')";
// Execute the query
$result = mysql_query($sql);
echo "Thank you! Information entered.";
}
else
{
// display form
?>
<form method="post" action="<?php echo $PHP_SELF?>">
First name:<input type="Text" name="first"><br>
Last name:<input type="Text" name="last"><br>
Address:<input type="Text" name="address"><br>
Position:<input type="Text" name="position"><br>
<input type="Submit" name="submit" value="Enter
information">
</form>
<?php
} // end if
?>
</body>
</html>
64. Integrating PHP with Embedded System
www.researchdesignlab.com Page 64
OUTPUT of the above given Example would be:
66. Integrating PHP with Embedded System
www.researchdesignlab.com Page 66
Update the data present in MYSQL
database using web form
<html>
<body>
<?php
// Open MYSQL server connection
$db = mysql_connect("localhost", "root","q1w2e3r4/");
// Select the database using MYSQL server connection
mysql_select_db("mydb",$db);
if ($id) {
if ($submit) {
// Write UPDATE query and assign to $sql Variable
$sql = "UPDATE employees SET
first='$first', last='$last',
address='$address',
position='$position'
WHERE id=$id";
// Execute the query
$result = mysql_query($sql);
echo "Thank you! Information updated.";
}
else
{
// Write query to SELECT data from table
$sql = "SELECT * FROM employees WHERE id=$id";
// Execute the query
$result = mysql_query($sql);
// Fetch the values
$myrow = mysql_fetch_array($result);
?>
<form method="post" action="<?php echo $PHP_SELF?>">
<input type=hidden name="id" value="<?php echo
$myrow["id"] ?>">
First name:<input type="Text" name="first"
value="<?php echo $myrow["first"] ?>"><br>
Last name:<input type="Text" name="last"
value="<?php echo $myrow["last"] ?>"><br>
Address:<input type="Text" name="address"
value="<?php echo $myrow["address"]?>"><br>
Position:<input type="Text" name="position"
value="<?php echo $myrow["position"]?>"><br>
<input type="Submit" name="submit" value="Enter
information">
</form>
67. Integrating PHP with Embedded System
www.researchdesignlab.com Page 67
<?php
}
}
else
{
// display list of employees
$result = mysql_query("SELECT * FROM
employees",$db);
while ($myrow = mysql_fetch_array($result)) {
printf("<a href="%s?id=%s">%s %s</a><br>",
$PHP_SELF, $myrow["id"],$myrow["first"],
$myrow["last"]);
}
}
?>
</body>
</html>
68. Integrating PHP with Embedded System
www.researchdesignlab.com Page 68
OUTPUT of the above given Example would be:
70. Integrating PHP with Embedded System
www.researchdesignlab.com Page 70
Delete the data from MYSQL database
using web form
<html>
<body>
<?php
// Open MYSQL server connection
$db = mysql_connect("localhost", "root","q1w2e3r4/");
// Select the database using MYSQL server connection
mysql_select_db("mydb",$db);
if ($id) {
if ($submit) {
// Write DELETE query to delete data from table based on ID
$sql = "DELETE FROM employees WHERE id=$id";
// Execute the query
$result = mysql_query($sql);
echo "Thank you! Information deleted.";
}
else
{
// Write SELECT query to select data from table based on ID
$sql = "SELECT * FROM employees WHERE id=$id";
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);
?>
<form method="post" action="<?php echo $PHP_SELF?>">
<input type=hidden name="id"
value="<?php echo $myrow["id"] ?>">
First name:<input type="Text" name="first"
readonly="readonly"
value="<?php echo $myrow["first"] ?>"><br>
Last name:<input type="Text" name="last"
readonly="readonly"
value="<?php echo $myrow["last"] ?>"><br>
Address:<input type="Text" name="address"
readonly="readonly"
value="<?php echo $myrow["address"]?>"><br>
Position:<input type="Text" name="position"
value="<?php echo $myrow["position"]?>"><br>
<input type="Submit" name="submit"
value="Delete information">
</form>
<?php
}
}
else
71. Integrating PHP with Embedded System
www.researchdesignlab.com Page 71
{
// display list of employees
$result = mysql_query("SELECT * FROM
employees",$db);
while ($myrow = mysql_fetch_array($result)) {
printf("<a href="%s?id=%s">%s %s</a><br>",
$PHP_SELF, $myrow["id"],$myrow["first"],
$myrow["last"]);
}
}
?>
</body>
</html>
OUTPUT of the above given Example would be:
74. Integrating PHP with Embedded System
www.researchdesignlab.com Page 74
Hosting your domain using cPanel
Step 1:
Register your required Domain name by visiting godaddy.com
75. Integrating PHP with Embedded System
www.researchdesignlab.com Page 75
Step 2:
Buy required domain Space to upload your code
76. Integrating PHP with Embedded System
www.researchdesignlab.com Page 76
Step 3:
Launch your cPanel – your-domain-name.com/cPanel
Provide your cPanel username and password click on login
77. Integrating PHP with Embedded System
www.researchdesignlab.com Page 77
Step 4:
Click on file Manger
78. Integrating PHP with Embedded System
www.researchdesignlab.com Page 78
Step 5:
Click on Web root and Go
79. Integrating PHP with Embedded System
www.researchdesignlab.com Page 79
Step 6:
Select the Public Folder_html
80. Integrating PHP with Embedded System
www.researchdesignlab.com Page 80
Step 7:
Click on Upload
81. Integrating PHP with Embedded System
www.researchdesignlab.com Page 81
Step 8:
Click on the choose file to upload your code
Note:
Once the code is uploaded your website will be live on internet. That you
can check with open the browser with your-domain-name.com
82. Integrating PHP with Embedded System
www.researchdesignlab.com Page 82
Step 9:
To create database – click on the phpMyAdmin
83. Integrating PHP with Embedded System
www.researchdesignlab.com Page 83
Step 10:
Manage your Tables and database on phpMyAdmin console
84. Integrating PHP with Embedded System
www.researchdesignlab.com Page 84
Step 11:
Importing Database or table by clicking on import
85. Integrating PHP with Embedded System
www.researchdesignlab.com Page 85
Step 12:
Exporting your database to local machine
86. Integrating PHP with Embedded System
www.researchdesignlab.com Page 86
EMBEDDED SYSTEM WITH PHP
OVERVIEW
This Ethernet Breakout-Module is simplest way to add LAN connectivity to your microcontroller
based products and projects. Use this module to enable Ethernet interface for your product. It works
with any microcontroller operating at 3.3V or 5V. This module works at 3.3V and is compatible with
5V interface lines.
FEATURES
Brand new and high quality.
Chip board ENC28J60-I/SO.
The board 25MHZ crystal.
The network interface board
HR911105A.
3.3 V power supply pin.
Size: 6cm x 3.2cm - 2.4inch x 1.28inch.
High quality PCB FR4 Grade with FPT
Certified
APPLICATION DIAGRAM
87. Integrating PHP with Embedded System
www.researchdesignlab.com Page 87
CIRCUIT DIAGRAM
88. Integrating PHP with Embedded System
www.researchdesignlab.com Page 88
PIN CONNECTION
89. Integrating PHP with Embedded System
www.researchdesignlab.com Page 89
INTERFACE
LIBRARY
(add this library on your arduino folder in program files)
https://drive.google.com/file/d/0BzrGD4zr88GnZFRRalNjU1E0UmM/view
90. Integrating PHP with Embedded System
www.researchdesignlab.com Page 90
CODE
With Arduino
1. ADD hello world example from Examples
2. Add Server Reading Example
91. Integrating PHP with Embedded System
www.researchdesignlab.com Page 91
3. relay interface(Web Remote)
code:
#include "etherShield.h"
#include "ETHER_28J60.h"
int outputPin1 = 2;
int outputPin2 = 3;
int outputPin3 = 4;
int outputPin4 = 5;
static uint8_t mac[6] = {0x54, 0x55, 0x58, 0x10, 0x00, 0x24}; // this just needs to be unique
for your network,
// so unless you have more than one of these boards
// connected, you should be fine with this value.
static uint8_t ip[4] = {192, 168, 1, 15}; // the IP address for your board. Check your home
hub
// to find an IP address not in use and pick that
// this or 10.0.0.15 are likely formats for an address
// that will work.
static uint16_t port = 80; // Use port 80 - the standard for HTTP
ETHER_28J60 e;
char flag1=0,flag2=0,flag3=0,flag4=0;
void setup()
{
106. Integrating PHP with Embedded System
www.researchdesignlab.com Page 106
3. With Pic 16F877A
PIN CONNECTION
107. Integrating PHP with Embedded System
www.researchdesignlab.com Page 107
code
/*
* Project Name:
httpserver_example (Ethernet Library http server demo for ENC28J60 mcu)
* Copyright:
(c) Mikroelektronika, 2005-2010.
* Revision History:
2007/12/10:
- initial release; Author: Bruno Gavand.
2010/12/20:
- modified for PRO compilers (FJ);
2012/10/19:
Modifier pour usage personnel
* description :
* this code shows how to use the Spi_Ethernet mini library :
* the board will reply to ARP & ICMP echo requests
* the board will reply to HTTP requests on port 80, GET method with pathnames :
* / will return the HTML main page
* /s will return board status as text string
* /t0 ... /t7 will toggle PD0 to PD7 bit and return HTML main page
* all other requests return also HTML main page
* Test configuration:
MCU: PIC16F877A
http://ww1.microchip.com/downloads/en/DeviceDoc/41291D.pdf
Dev.Board: PIC-Ready1
http://www.mikroe.com/products/view/177/pic-ready-prototype-board/
http://www.mikroe.com/products/view/305/pic-ready1-board/
Oscillator: External Clock 8.0000 MHz
Ext. Modules: ac:Serial_Ethernet_board
http://www.mikroe.com/eng/products/view/14/serial-ethernet-board/
SW: mikroC PRO for PIC
http://www.mikroe.com/en/compilers/mikroc/pro/pic/
* NOTES:
- Connect Serial Ethernet Board on PortC (Board and MCU Specific)
- Since the ENC28J60 doesn't support auto-negotiation, full-duplex mode is
not compatible with most switches/routers. If a dedicated network is used
where the duplex of the remote node can be manually configured, you may
change this configuration. Otherwise, half duplex should always be used.
- External power supply should be used due to Serial Ethernet Board power consumption.
*/
/*
Pour voir l'états des variables tapper : 192.168.0.170/s
108. Integrating PHP with Embedded System
www.researchdesignlab.com Page 108
Pour faire une commande d'interrupteur faire :
192.168.0.170/dXo ouvre(OFF)
192.168.0.170/dXf ferme(ON)
avec X pour valeur : 0 a 7
*/
// duplex config flags
#define Spi_Ethernet_HALFDUPLEX 0x00 // half duplex
#define Spi_Ethernet_FULLDUPLEX 0x01 // full duplex
// mE ehternet NIC pinout
sfr sbit SPI_Ethernet_Rst at RC0_bit;
sfr sbit SPI_Ethernet_CS at RC1_bit;
sfr sbit SPI_Ethernet_Rst_Direction at TRISC0_bit;
sfr sbit SPI_Ethernet_CS_Direction at TRISC1_bit;
// end ethernet NIC definitions
typedef struct
{
unsigned canCloseTCP: 1; // flag which closes TCP socket (not relevant to UDP)
unsigned isBroadcast: 1; // flag which denotes that the IP package has been received via subnet
broadcast address (not used for PIC16 family)
} TEthPktFlags;
/************************************************************
* ROM constant strings
*/
const unsigned char httpHeader[] = "HTTP/1.1 200 OKnContent-type: " ; // HTTP header
const unsigned char httpMimeTypeHTML[] = "text/htmlnn" ; // HTML MIME type
const unsigned char httpMimeTypeScript[] = "text/plainnn" ; // TEXT MIME type
unsigned char httpMethod[] = "GET /";
/*
* web page, splited into 2 parts :
* when coming short of ROM, fragmented data is handled more efficiently by linker
*
* this HTML page calls the boards to get its status, and builds itself with javascript
*/
//*************************************************************************
// Change the IP address of the page to be refreshed
const char *indexPageHEAD = "<meta http-equiv='refresh' content='10;url=http://192.168.1.15/'>
<HTML><HEAD></HEAD><BODY>
<h1>RESEARCH DESIGN LAB,<p> </h1>
<p><a href="http://olivier.fournet.free.fr/e.html">NOTICE</a><p>
<p><a href=/>Reload</a><p>
<script src=/s></script>";
const char *indexPageBODY = "<table><tr><td valign=top><table border=1 style='font-size:20px;
font-family: terminal;'>
<tr><th colspan=2>ADC</th></tr>
<tr><td>AN2</td><td><script>document.write(AN2);</script></td></tr>
110. Integrating PHP with Embedded System
www.researchdesignlab.com Page 110
unsigned char dyna[30]; // buffer for dynamic response
unsigned long httpCounter = 0; // counter of HTTP requests
/*******************************************
* functions
*/
/*
* put the constant string pointed to by s to the ENC transmit buffer.
*/
/*unsigned int putConstString(const char *s)
{
unsigned int ctr = 0 ;
while(*s)
{
Spi_Ethernet_putByte(*s++) ;
ctr++ ;
}
return(ctr) ;
}*/
/*
* it will be much faster to use library Spi_Ethernet_putConstString routine
* instead of putConstString routine above. However, the code will be a little
* bit bigger. User should choose between size and speed and pick the implementation that
* suites him best. If you choose to go with the putConstString definition above
* the #define line below should be commented out.
*
*/
#define putConstString SPI_Ethernet_putConstString
/*
* put the string pointed to by s to the ENC transmit buffer
*/
/*unsigned int putString(char *s)
{
unsigned int ctr = 0 ;
while(*s)
{
Spi_Ethernet_putByte(*s++) ;
ctr++ ;
}
return(ctr) ;
}*/
/*
* it will be much faster to use library Spi_Ethernet_putString routine
* instead of putString routine above. However, the code will be a little
* bit bigger. User should choose between size and speed and pick the implementation that
* suites him best. If you choose to go with the putString definition above
111. Integrating PHP with Embedded System
www.researchdesignlab.com Page 111
* the #define line below should be commented out.
*
*/
#define putString SPI_Ethernet_putString
/*
* this function is called by the library
* the user accesses to the HTTP request by successive calls to Spi_Ethernet_getByte()
* the user puts data in the transmit buffer by successive calls to Spi_Ethernet_putByte()
* the function must return the length in bytes of the HTTP reply, or 0 if nothing to transmit
*
* if you don't need to reply to HTTP requests,
* just define this function with a return(0) as single statement
*
*/
unsigned int SPI_Ethernet_UserTCP(unsigned char *remoteHost, unsigned int remotePort,
unsigned int localPort, unsigned int reqLength, TEthPktFlags *flags)
{
unsigned int len = 0 ; // my reply length
unsigned int i ; // general purpose integer
// should we close tcp socket after response is sent?
// library closes tcp socket by default if canClose flag is not reset here
// flags->canClose = 0; // 0 - do not close socket
// otherwise - close socket
if(localPort != 80)
{ // I listen only to web request on port 80
return(0) ;
}
// get 10 first bytes only of the request, the rest does not matter here
for(i = 0 ; i < 10 ; i++)
{
getRequest[i] = SPI_Ethernet_getByte() ;
}
getRequest[i] = 0 ;
if(memcmp(getRequest, httpMethod, 5))
{ // only GET method is supported here
return(0) ;
}
httpCounter++ ; // one more request done
get_Request = getRequest[5]; // s , d
if(get_Request == 's') // utiliser pour <script src=/s></script>
{
// if request path name starts with s, store dynamic data in transmit buffer
112. Integrating PHP with Embedded System
www.researchdesignlab.com Page 112
// the text string replied by this request can be interpreted as javascript statements
// by browsers
len = putConstString(httpHeader); // HTTP header
len += putConstString(httpMimeTypeScript); // with text MIME type
// add AN2 value to reply
IntToStr(ADC_Read(2), dyna);
len += putConstString("var AN2=");
len += putString(dyna);
len += putConstString(";");
// add AN3 value to reply
IntToStr(ADC_Read(3), dyna);
len += putConstString("var AN3=");
len += putString(dyna);
len += putConstString(";");
// add PORTB value (buttons) to reply
len += putConstString("var PORTB=");
IntToStr(PORTB, dyna);
len += putString(dyna);
len += putConstString(";");
// add PORTD value (LEDs) to reply
len += putConstString("var PORTD=");
IntToStr(PORTD, dyna);
len += putString(dyna);
len += putConstString(";");
// add HTTP requests counter to reply
IntToStr(httpCounter, dyna);
len += putConstString("var REQ=");
len += putString(dyna);
len += putConstString(";");
}
else
{
//
if(get_Request == 'd') // Commande PORTD
{
if( isdigit(getRequest[6]) )
{
digit_getRequest = getRequest[6] - '0'; // numéro de port 0 à 7
if( getRequest[7] == 'o' ) // Contact Ouvert (OFF)
etat_interrupteur = 0;
if( getRequest[7] == 'f' ) // Contact Fermer (ON)
etat_interrupteur = 1;
switch(digit_getRequest)
113. Integrating PHP with Embedded System
www.researchdesignlab.com Page 113
{
case 0: PORTD.B0 = etat_interrupteur; break;
case 1: PORTD.B1 = etat_interrupteur; break;
case 2: PORTD.B2 = etat_interrupteur; break;
case 3: PORTD.B3 = etat_interrupteur; break;
case 4: PORTD.B4 = etat_interrupteur; break;
case 5: PORTD.B5 = etat_interrupteur; break;
case 6: PORTD.B6 = etat_interrupteur; break;
case 7: PORTD.B7 = etat_interrupteur; break;
}
}
}
//
}
if(len == 0)
{ // what do to by default
len = putConstString(httpHeader); // HTTP header
len += putConstString(httpMimeTypeHTML); // with HTML MIME type
len += putConstString(indexPageHEAD); // HTML page first part
len += putConstString(indexPageBODY); // HTML page second part
len += putConstString(indexPageBODY2); // HTML page second part
}
return(len) ; // return to the library with the number of bytes to transmit
}
/*
* this function is called by the library
* the user accesses to the UDP request by successive calls to Spi_Ethernet_getByte()
* the user puts data in the transmit buffer by successive calls to Spi_Ethernet_putByte()
* the function must return the length in bytes of the UDP reply, or 0 if nothing to transmit
*
* if you don't need to reply to UDP requests,
* just define this function with a return(0) as single statement
*
*/
unsigned int SPI_Ethernet_UserUDP(unsigned char *remoteHost, unsigned int remotePort,
unsigned int destPort, unsigned int reqLength, TEthPktFlags *flags)
{
return 0; // back to the library with the length of the UDP reply
}
/*
* main entry
*/
void main()
{
//ANSEL = 0x0C ; // AN2 and AN3 convertors will be used
//C1ON_bit = 0; // Disable comparators
//C2ON_bit = 0;
114. Integrating PHP with Embedded System
www.researchdesignlab.com Page 114
PORTA = 0 ;
TRISA = 0xff ; // set PORTA as input for ADC
//ANSELH = 0; // Configure other AN pins as digital I/O
PORTB = 0 ;
TRISB = 0xff ; // set PORTB as input for buttons
PORTD = 0 ;
TRISD = 0 ; // set PORTD as output
/*
* starts ENC28J60 with :
* reset bit on RC0
* CS bit on RC1
* my MAC & IP address
* full duplex
*/
SPI1_Init();
SPI_Ethernet_Init(myMacAddr, myIpAddr, Spi_Ethernet_FULLDUPLEX) ;
while(1)
{ // do forever
/*
* if necessary, test the return value to get error code
*/
SPI_Ethernet_doPacket() ; // process incoming Ethernet packets
/*
* add your stuff here if needed
* Spi_Ethernet_doPacket() must be called as often as possible
* otherwise packets could be lost
*/
}
}