The document provides an introduction to programming concepts such as variables, data types, basic math operations, and order of operations. It explains how variables store and represent data in computer memory and how their values can be manipulated using assignment statements and basic math. The document also introduces potential issues around data type conversion and order of operations that programmers need to be aware of.
Slides from our CodeMash 2013 Precompiler session, "Web Development with Python and Django", including a breezy introduction to the Python programming language and the Django web framework. The example code repository is available at https://github.com/finiteloopsoftware/django-precompiler/
Slides from our CodeMash 2013 Precompiler session, "Web Development with Python and Django", including a breezy introduction to the Python programming language and the Django web framework. The example code repository is available at https://github.com/finiteloopsoftware/django-precompiler/
How to measure and optimize performance of applications that use Zend Framework 1.x. A talk presented at the New York City Zend Framework Meetup (http://www.meetup.com/ZendFramework-NYCmetro/) on August 23, 2011.
Strategic Modernization with PHP on IBM iAlan Seiden
You know you need to modernize your IBM i applications, but where to start? In this talk, Alan will inspire you with creative examples of modernization on IBM i that provided a strong return on investment while controlling risk. Learn how to choose projects with the best return on investment, and then complete them with confidence. We will lead an honest discussion of the most effective strategies. Can RPG programmers learn PHP? Yes. Can new PHP developers be integrated into an existing IT department? Yes. Both approaches have merit. See creative ways to use PHP, not only to create new GUI front-ends, but to enhance existing interactive RPG programs. Please your users and business people by incorporating PHP into your shop.
Recent advances in DB2 and SQL can make PHP applications more secure, efficient, and require less code. Learn how to take advantage of a true enterprise-grade database: DB2 for IBM i. This tutorial will show the right way to use DB2 with PHP. Topics include: RCAC row and column security built into DB2, techniques to reduce the amount of required boilerplate PHP database code, new features of DB2 and ibm_db2 that can make life easier for developers, detailed performance tips, prevention of SQL injection, library list options, connecting to IBM i's DB2 from Windows and Linux, implementing pagination, using Zend\Db, and more. With new material presented for the first time anywhere.
Php Dependency Management with Composer ZendCon 2016Clark Everetts
A deep-dive for beginners into Composer, the dependency manager for PHP. Learn how Composer helps you obtain the components your applications depend upon, installs them into your project, and controls their update to newer versions.
Low level, High level and Middle level programming languages
,Bug and Debugging ,difference between compiler and interpreter,instructions and program,source code and object code ,language translators
Zend con 2016 bdd with behat for beginnersAdam Englander
Learn the basics of behavioral driven development (BDD) with Behat to build high quality and well documented applications. You'll learn how BDD can help you deliver greater business value more efficiently while accurately documenting the functionality of your application along the way. You'll learn how to utilize Behat as your BDD tool. With Behat, you'll create tests for the features in your application by utilizing a natural language syntax called Gherkin backed by PHP code to execute the steps executed in the feature's scenarios.
This will be a hands-on tutorial. You'll learn how to implement BDD for a web application. This will include utilizing Selenium WebDriver for real world multi-browser testing including introductions to Selenium Grid and hosted integration services utilizing Selenium.
Content Management Systems and Refactoring - Drupal, WordPress and eZ PublishJani Tarvainen
Content Management has come of age and systems need to move forward. Tools such as WordPress, Drupal and eZ Publish have evolved to what they are rather organically. Now they face the challenge of renewing themselves.
A Bug Hunter's Perspective on Unix DriversJeremy Brown
The Unix driver space with regards to security has been understudied compared to it’s vast attack surface. One juicy area that can be especially buggy and accessible in drivers, I/O control, has received much more attention on Windows than Unix OSes. In this presentation, I will give an introduction to this particular attack surface on Linux, why bugs here are a significant threat and show you how get started looking for vulnerabilities in drivers on the platform. I’ll also go into some of the tools and techniques available and talk about a new tool I’ve written that can help bug hunters dig into Unix device drivers.
Create a welcoming development environment on IBM iAlan Seiden
Thanks to languages such as PHP, young developers are entering the IBM i world, but may be unprepared for their new environment. They may not realize that IBM i has an SSH shell environment that can have them feeling at home and productive.
This talk will offer tools and tips to allow developers to work from a UNIX command line in the manner they may be used to (with minor adjustments) on IBM i. Improve job satisfaction with the tips presented here.
Topics will include:
* create a chroot environment for safe experimentation on IBM i
* install bash shell with tab autocomplete and other familar features
* access DB2 and IBM i operations from the command line
* use familiar editing tools such as vi
* use php-cli efficiently
What is HHVM? How does it compare to other PHP implementations? Should I be using it? How stable is it?
HHVM is an open-source virtual machine designed for executing programs written in Hack and PHP. HHVM uses a just-in-time (JIT) compilation approach to achieve superior performance while maintaining the development flexibility that PHP provides.
From Zero to ZF: Your first zend framework project on ibm iAlan Seiden
Step by step, I'll demonstrate the creation of a Zend Framework (ZF) project, with special attention to configuring the db2 adapter so it works well with IBM i.
Lectures available at:
https://www.youtube.com/playlist?list=PL9Rh1XF68iO1Cz_RvF-DJ724ueHa70At6
This slides contains all the basic contents related C programming.
Slide contents:
1. Basic Computer Hardware
2. Learning C Basics
3. Variable, constants
4. Operators
5. Decision making
6. Looping
7. Arrays & Function
8. String
9. Structure and Union
10. C Pointers
11. Files in C
12. Dynamic Memory Allocation
13. Summary
14. Practice Problems
How to measure and optimize performance of applications that use Zend Framework 1.x. A talk presented at the New York City Zend Framework Meetup (http://www.meetup.com/ZendFramework-NYCmetro/) on August 23, 2011.
Strategic Modernization with PHP on IBM iAlan Seiden
You know you need to modernize your IBM i applications, but where to start? In this talk, Alan will inspire you with creative examples of modernization on IBM i that provided a strong return on investment while controlling risk. Learn how to choose projects with the best return on investment, and then complete them with confidence. We will lead an honest discussion of the most effective strategies. Can RPG programmers learn PHP? Yes. Can new PHP developers be integrated into an existing IT department? Yes. Both approaches have merit. See creative ways to use PHP, not only to create new GUI front-ends, but to enhance existing interactive RPG programs. Please your users and business people by incorporating PHP into your shop.
Recent advances in DB2 and SQL can make PHP applications more secure, efficient, and require less code. Learn how to take advantage of a true enterprise-grade database: DB2 for IBM i. This tutorial will show the right way to use DB2 with PHP. Topics include: RCAC row and column security built into DB2, techniques to reduce the amount of required boilerplate PHP database code, new features of DB2 and ibm_db2 that can make life easier for developers, detailed performance tips, prevention of SQL injection, library list options, connecting to IBM i's DB2 from Windows and Linux, implementing pagination, using Zend\Db, and more. With new material presented for the first time anywhere.
Php Dependency Management with Composer ZendCon 2016Clark Everetts
A deep-dive for beginners into Composer, the dependency manager for PHP. Learn how Composer helps you obtain the components your applications depend upon, installs them into your project, and controls their update to newer versions.
Low level, High level and Middle level programming languages
,Bug and Debugging ,difference between compiler and interpreter,instructions and program,source code and object code ,language translators
Zend con 2016 bdd with behat for beginnersAdam Englander
Learn the basics of behavioral driven development (BDD) with Behat to build high quality and well documented applications. You'll learn how BDD can help you deliver greater business value more efficiently while accurately documenting the functionality of your application along the way. You'll learn how to utilize Behat as your BDD tool. With Behat, you'll create tests for the features in your application by utilizing a natural language syntax called Gherkin backed by PHP code to execute the steps executed in the feature's scenarios.
This will be a hands-on tutorial. You'll learn how to implement BDD for a web application. This will include utilizing Selenium WebDriver for real world multi-browser testing including introductions to Selenium Grid and hosted integration services utilizing Selenium.
Content Management Systems and Refactoring - Drupal, WordPress and eZ PublishJani Tarvainen
Content Management has come of age and systems need to move forward. Tools such as WordPress, Drupal and eZ Publish have evolved to what they are rather organically. Now they face the challenge of renewing themselves.
A Bug Hunter's Perspective on Unix DriversJeremy Brown
The Unix driver space with regards to security has been understudied compared to it’s vast attack surface. One juicy area that can be especially buggy and accessible in drivers, I/O control, has received much more attention on Windows than Unix OSes. In this presentation, I will give an introduction to this particular attack surface on Linux, why bugs here are a significant threat and show you how get started looking for vulnerabilities in drivers on the platform. I’ll also go into some of the tools and techniques available and talk about a new tool I’ve written that can help bug hunters dig into Unix device drivers.
Create a welcoming development environment on IBM iAlan Seiden
Thanks to languages such as PHP, young developers are entering the IBM i world, but may be unprepared for their new environment. They may not realize that IBM i has an SSH shell environment that can have them feeling at home and productive.
This talk will offer tools and tips to allow developers to work from a UNIX command line in the manner they may be used to (with minor adjustments) on IBM i. Improve job satisfaction with the tips presented here.
Topics will include:
* create a chroot environment for safe experimentation on IBM i
* install bash shell with tab autocomplete and other familar features
* access DB2 and IBM i operations from the command line
* use familiar editing tools such as vi
* use php-cli efficiently
What is HHVM? How does it compare to other PHP implementations? Should I be using it? How stable is it?
HHVM is an open-source virtual machine designed for executing programs written in Hack and PHP. HHVM uses a just-in-time (JIT) compilation approach to achieve superior performance while maintaining the development flexibility that PHP provides.
From Zero to ZF: Your first zend framework project on ibm iAlan Seiden
Step by step, I'll demonstrate the creation of a Zend Framework (ZF) project, with special attention to configuring the db2 adapter so it works well with IBM i.
Lectures available at:
https://www.youtube.com/playlist?list=PL9Rh1XF68iO1Cz_RvF-DJ724ueHa70At6
This slides contains all the basic contents related C programming.
Slide contents:
1. Basic Computer Hardware
2. Learning C Basics
3. Variable, constants
4. Operators
5. Decision making
6. Looping
7. Arrays & Function
8. String
9. Structure and Union
10. C Pointers
11. Files in C
12. Dynamic Memory Allocation
13. Summary
14. Practice Problems
PHP Programming course provides the knowledge necessary to design and develop dynamic, database-driven web pages using PHP version 5. PHP is a language written for the web, quick to learn, easy to deploy and provides substantial functionality required for e-commerce. This course introduces the PHP framework and syntax, and covers in depth the most important techniques used to build dynamic web sites. Students also learn how to configure PHP and the Apache Web Server. Comprehensive hands on exercises are integrated throughout to reinforce learning and develop real competency.
Elevating Tactical DDD Patterns Through Object CalisthenicsDorra BARTAGUIZ
After immersing yourself in the blue book and its red counterpart, attending DDD-focused conferences, and applying tactical patterns, you're left with a crucial question: How do I ensure my design is effective? Tactical patterns within Domain-Driven Design (DDD) serve as guiding principles for creating clear and manageable domain models. However, achieving success with these patterns requires additional guidance. Interestingly, we've observed that a set of constraints initially designed for training purposes remarkably aligns with effective pattern implementation, offering a more ‘mechanical’ approach. Let's explore together how Object Calisthenics can elevate the design of your tactical DDD patterns, offering concrete help for those venturing into DDD for the first time!
GraphRAG is All You need? LLM & Knowledge GraphGuy Korland
Guy Korland, CEO and Co-founder of FalkorDB, will review two articles on the integration of language models with knowledge graphs.
1. Unifying Large Language Models and Knowledge Graphs: A Roadmap.
https://arxiv.org/abs/2306.08302
2. Microsoft Research's GraphRAG paper and a review paper on various uses of knowledge graphs:
https://www.microsoft.com/en-us/research/blog/graphrag-unlocking-llm-discovery-on-narrative-private-data/
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionAggregage
Join Maher Hanafi, VP of Engineering at Betterworks, in this new session where he'll share a practical framework to transform Gen AI prototypes into impactful products! He'll delve into the complexities of data collection and management, model selection and optimization, and ensuring security, scalability, and responsible use.
The Art of the Pitch: WordPress Relationships and SalesLaura Byrne
Clients don’t know what they don’t know. What web solutions are right for them? How does WordPress come into the picture? How do you make sure you understand scope and timeline? What do you do if sometime changes?
All these questions and more will be explored as we talk about matching clients’ needs with what your agency offers without pulling teeth or pulling your hair out. Practical tips, and strategies for successful relationship building that leads to closing the deal.
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf91mobiles
91mobiles recently conducted a Smart TV Buyer Insights Survey in which we asked over 3,000 respondents about the TV they own, aspects they look at on a new TV, and their TV buying preferences.
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofsAlex Pruden
This paper presents Reef, a system for generating publicly verifiable succinct non-interactive zero-knowledge proofs that a committed document matches or does not match a regular expression. We describe applications such as proving the strength of passwords, the provenance of email despite redactions, the validity of oblivious DNS queries, and the existence of mutations in DNA. Reef supports the Perl Compatible Regular Expression syntax, including wildcards, alternation, ranges, capture groups, Kleene star, negations, and lookarounds. Reef introduces a new type of automata, Skipping Alternating Finite Automata (SAFA), that skips irrelevant parts of a document when producing proofs without undermining soundness, and instantiates SAFA with a lookup argument. Our experimental evaluation confirms that Reef can generate proofs for documents with 32M characters; the proofs are small and cheap to verify (under a second).
Paper: https://eprint.iacr.org/2023/1886
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
The publishing industry has been selling digital audiobooks and ebooks for over a decade and has found its groove. What’s changed? What has stayed the same? Where do we go from here? Join a group of leading sales peers from across the industry for a conversation about the lessons learned since the popularization of digital books, best practices, digital book supply chain management, and more.
Link to video recording: https://bnctechforum.ca/sessions/selling-digital-books-in-2024-insights-from-industry-leaders/
Presented by BookNet Canada on May 28, 2024, with support from the Department of Canadian Heritage.
Accelerate your Kubernetes clusters with Varnish CachingThijs Feryn
A presentation about the usage and availability of Varnish on Kubernetes. This talk explores the capabilities of Varnish caching and shows how to use the Varnish Helm chart to deploy it to Kubernetes.
This presentation was delivered at K8SUG Singapore. See https://feryn.eu/presentations/accelerate-your-kubernetes-clusters-with-varnish-caching-k8sug-singapore-28-2024 for more details.
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™UiPathCommunity
In questo evento online gratuito, organizzato dalla Community Italiana di UiPath, potrai esplorare le nuove funzionalità di Autopilot, il tool che integra l'Intelligenza Artificiale nei processi di sviluppo e utilizzo delle Automazioni.
📕 Vedremo insieme alcuni esempi dell'utilizzo di Autopilot in diversi tool della Suite UiPath:
Autopilot per Studio Web
Autopilot per Studio
Autopilot per Apps
Clipboard AI
GenAI applicata alla Document Understanding
👨🏫👨💻 Speakers:
Stefano Negro, UiPath MVPx3, RPA Tech Lead @ BSP Consultant
Flavio Martinelli, UiPath MVP 2023, Technical Account Manager @UiPath
Andrei Tasca, RPA Solutions Team Lead @NTT Data
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!
State of ICS and IoT Cyber Threat Landscape Report 2024 previewPrayukth K V
The IoT and OT threat landscape report has been prepared by the Threat Research Team at Sectrio using data from Sectrio, cyber threat intelligence farming facilities spread across over 85 cities around the world. In addition, Sectrio also runs AI-based advanced threat and payload engagement facilities that serve as sinks to attract and engage sophisticated threat actors, and newer malware including new variants and latent threats that are at an earlier stage of development.
The latest edition of the OT/ICS and IoT security Threat Landscape Report 2024 also covers:
State of global ICS asset and network exposure
Sectoral targets and attacks as well as the cost of ransom
Global APT activity, AI usage, actor and tactic profiles, and implications
Rise in volumes of AI-powered cyberattacks
Major cyber events in 2024
Malware and malicious payload trends
Cyberattack types and targets
Vulnerability exploit attempts on CVEs
Attacks on counties – USA
Expansion of bot farms – how, where, and why
In-depth analysis of the cyber threat landscape across North America, South America, Europe, APAC, and the Middle East
Why are attacks on smart factories rising?
Cyber risk predictions
Axis of attacks – Europe
Systemic attacks in the Middle East
Download the full report from here:
https://sectrio.com/resources/ot-threat-landscape-reports/sectrio-releases-ot-ics-and-iot-security-threat-landscape-report-2024/
A tale of scale & speed: How the US Navy is enabling software delivery from l...sonjaschweigert1
Rapid and secure feature delivery is a goal across every application team and every branch of the DoD. The Navy’s DevSecOps platform, Party Barge, has achieved:
- Reduction in onboarding time from 5 weeks to 1 day
- Improved developer experience and productivity through actionable findings and reduction of false positives
- Maintenance of superior security standards and inherent policy enforcement with Authorization to Operate (ATO)
Development teams can ship efficiently and ensure applications are cyber ready for Navy Authorizing Officials (AOs). In this webinar, Sigma Defense and Anchore will give attendees a look behind the scenes and demo secure pipeline automation and security artifacts that speed up application ATO and time to production.
We will cover:
- How to remove silos in DevSecOps
- How to build efficient development pipeline roles and component templates
- How to deliver security artifacts that matter for ATO’s (SBOMs, vulnerability reports, and policy evidence)
- How to streamline operations with automated policy checks on container images
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Albert Hoitingh
In this session I delve into the encryption technology used in Microsoft 365 and Microsoft Purview. Including the concepts of Customer Key and Double Key Encryption.
2. Where are we?
• Web Technology Stack
• 10 Minute Digression on Servers
– Client/server model
– Server Architecture
– Server Software Background
• The physical vs. logical
– Where do my files live?
– Where are they processed?
• Introduction to Programming
2
3. Web Technology Stack
Data – What does it know?
Behavior – What does it do?
Behavior – What does it do?
Presentation – What does it look like?
Structure – What does this logically mean?
Richness
of the
Experience
4. Basic Server Architecture
HTTP request
` HTTP response
Web Browser Web Server Database Server
A server is a computer
PHP
This is the model! Script optimized to share
resources, such as files,
printers, web sites,
What is our physical databases, and email,
architecture? over a network.
5. About Apache
• The Apache http server project is an
effort to develop and maintain an open
source http server for modern operating
systems (Linux, MS, OSX, …). The goal is
to provide a secure, efficient, and
extensible server that meets all standards
• http://httpd.apache.org
• Maintained by the Apache foundation
6. Stats of Web Server types
http://www.greatstatistics.com/serverstats.php
7. What the Busiest 1M Websites use
Totals for Active Servers Across All Domains - May 2010
nginx lighttpd
9% 0%
Google
13%
Apache
Microsoft 59%
19%
8. About PHP
• PHP stood for Personal Home Page (like a shell script)
• PHP now stands for PHP: Hypertext Preprocessor
(yes, it’s a recursive definition)
• PHP is HTML-centric and lives inside/along side HTML
• PHP is used to generate dynamic web pages
• PHP runs on the web server
– When the user requests a dynamic web page (typically a
.php file), the web server calls the PHP interpreter to
read the requested file
– The PHP interpreter parses the PHP commands (code) and
typically generates an .html file, which is returned to the
user
– PHP can use data passed to it from the web page and
access data in a database server
9. About MySQL
• MySQL is an open source database server
that is available for all/most operating
systems
– SQL: Structured Query Language
• Introduced in 1995 with version 3.23
• Now, version 5.X
• How open source is MySQL?
– MySQL is owned by MySQL AB, a for profit firm
– In 2008, Sun Microsystems acquires MySQL AB
– In 2009, Oracle Corporation acquires Sun
Microsystems
10. Apache, PHP & MySQL
• These open source products are easily installed
by developers and used commercially
• Your OS, Apache, MySQL, PHP – [X A M P]!
– LAMP, WAMP, and MAMP
• LAMP stacks are widely used to serve many content
applications
– Webmail, Blogs, Wikis, CMSs, etc.
• Great for Virtual Hosting!
– It is the server stack you get for $5/month from
HostGator, GoDaddy, etc.
11. Introduction to Programming
• Slides are from a course teaching “young
people” to program
– Apologize if too elementary
– Apologize if too advanced
• There will be some opportunities to program
– All examples are online and expectation is that
you will run the examples and review them here
and for homework
11
12. What are the Attributes of Good Programmers?
• Humility
• Love of Learning
• Detail-orientedness
• Adaptability
• Passion
12
13. What is programming?
• Very simply, programming means telling a
computer to do something
– Computers are dumb machines
• A computer program is made up of a number of
instructions
– An instruction is a basic command given to a
computer, usually to do a single, specific thing
• Software is a program or a collection of programs
that run on your computer
– Sometimes the software runs on another computer
that yours is connected to, like a web server.
13
14. Programming Languages
• Inside, all computers use a
binary (0/1) language
– Humans don’t speak binary
very well
• A programming language
lets humans write in ways
we “understand”
– It is then translated into
binary for the computer to
use
• There are lots of
programming languages
– HTML, CSS, Javascript, PHP,
Perl, Python, Basic, C, C++,
Java, etc.
14
15. Vocabulary
• Instructions
– echo “Hello there!”;
• Keywords
– A keyword is a special word that is part of a programming language (also
called a reserved word).
• Coding/Editing
– Writing a number of instructions that will perform a specific set of functions
• Compiling
– Converting the “human readable” instructions into the binary language that
the computer understands
• Executing
– A fancy way of saying “running your program”
• Interpreting
– Sometimes, converting to binary and executiing takes place instruction by
instruction, this is interpreting
• Debugging
– The process of finding errors (bugs) and correcting them
15
16. What could go wrong?
• Syntax bugs – Errors prior to execution (perhaps in your editor)
– Syntax is the spelling and grammar rules for a programming language, a
syntax error means that something is typed that just won’t work
• Runtime bugs - Errors during execution
– Runtime errors usually crash or stop the execution of your program with
some clues, called a Traceback - like what file, line number, or even error
16
17. *Class caveats & kludges*
• All programming examples are on my server:
– http://jamesmarcus.net/bwa/introprog
• We will use our browsers as an output device to
print simple results – our test jig!
– We are not printing (real) web pages (yet)
– We do not have the ability to get input values (yet)
• The example PHP code is embedded in a
comment tag and can be viewed using “View
Source”
– Examples must be changed to run on your web server
17
18. The programming cycle
• Edit • Edit and Save
– Write code <1hello1.php>
• Execute • Execute <1hello1.php>
– Run a program – Browser:
– Get a webpage http://localhost/bwa/int
roprog/1hello1.php
• Test & Debug
– “Inspect what you
• Test & Debug the
expect” results
– If you find a bug, back – Review results for a
to editing! variety of inputs
18
19. Our first PHP program
• XAMPP Control – start web server!
• Create in /htdocs/bwa/introprog the file
<1hello1.php>
<?php
print “Hello”;
print “ and Hello to you.”;
?>
• Start and end of a PHP code block
• A PHP code block
• PHP instructions end with a ‘;’
19
20. Analyzing our first PHP program
• File naming convention
– Files that contain PHP code have a .php extension
• PHP code blocks start and end with:
– <?php and ?>
– PHP instructions end with a ‘;’
• PHP has two simple output statements:
– print
– echo
• Using the browser as a text output device
– Yet, it is still a browser
• We can add simple text formatting. How?
20
21. Playing with our first PHP program
• Add simple text/HTML formatting to
<1hello1.php> to create <1hello2.php>
• Introduce errors to <1hello2.php>
– Syntax errors: Where/when do syntax errors occur?
– Runtime errors: Where/when do runtime errors
occur?
• Multiple code blocks: <1hello3.php>
– What is going on in between the code blocks?:
<1hello4.php>
21
22. Memory & Variables - Remember Me!
• Most all ‘useful’ programs:
– Get input
– Process the input
– Produce output
22
23. Feed Me, Seymour
• The computer needs input
– But in order to do something with the input, the
computer has to remember it or keep it somewhere
– The computer keeps things, including input (and the
program itself), in its memory
• Computer memory - a bunch of on/off switches
– You can write to the memory (set the switches)
– You can read from the memory (look at how the
switches are set, without changing them)
23
24. Naming Memory
>> Teacher = “Mr. Morton” • What happened?
>> print Teacher – We created a thing that
is made up of (a string
of) characters and gave it
• What do you expect a name, Teacher
from this “pseudo- • The equal sign ‘=‘ says
code” code snippet? to assign or “make
equal to”
– You assigned the name
Mr. Morton Teacher to the string of
letters “Mr. Morton”
<2teacher1.php>
24
25. But wait…
• It’s just like if someone
said, “Write down your
address.”
– What would you write?
25
26. Variables
• Programmers do not have to
think about how and where
memory stores things (like the
string of letters)
– We assign a value to a name and
then retrieve the value later
• The name assigned to the
value, like Teacher, is called a
variable
26
27. Types of Variables
• Variables exist for
– Strings (series of characters)
– Numbers (integers, reals)
– And other interesting stuff
• Boolean: true/false
• Groups of groups of letters or numbers – arrays!
• Explicit variable declaration
• Implicit variable declaration
• And in between
27
31. What’s in a name?
• In most modern programming languages, you can call a
variable anything you want (well, almost):
• It can be as long as you want
• It can have letters and numbers in it, as well as special
characters, like the underscore character (_)
• It usually is case-sensitive (uppercase and lowercase
matter)
– Are teacher and TEACHER two different names?
• It cannot have spaces
• It may require a special starting character
• In PHP, variables start with $, i.e., $Teacher
• In other languages, read the documentation
31
32. String Variables
• A character, or series of characters (letters,
numbers, or punctuation), is called a string
– The way you state that you are making a string is
to put quotes around the characters
– PHP and other languages are not too fussy about
whether you use single or double quotes
$teacher = “Mr. Morton”;
$teacher = „Mr. Morton‟;
32
33. Numbers as Strings
Strings as Numbers
$first = 5;
$second = 3;
print $first + $second; <4concat1.php>
$first = „5‟;
$second = „3‟;
print $first + $second;
• Huh? Adding two strings?
– Is that what we mean to do?
33
34. Fancy word time: concatenate
• It’s not really correct to say we want to “add”
strings. (Though PHP lets us do so.)
• When you put characters or strings together
to make a longer string, we call it
concatenation.
• In PHP, two strings are concatenated by the
dot ‘.’ operator:
<4concat2.php>
$newstring = $string1 . $string2;
34
35. How variable is a variable?
• Variables are called “variables” for a reason
– It’s because they are . . . well . . . variable!
– The value assigned to them can vary or change
– Remember the MyTeacher example
35
36. How variable is variable?
$teacher = “Mr. Morton”;
$teacher = “Mr. Smith”;
$print teacher;
36
37. The new me!
• You can make a variable equal to itself:
$Score = 7;
$Score = $Score;
• Big woop! It is just the same old me.
$Score = $Score + 1;
print $Score;
• Woop, woop! It is a whole new me!
<5increment1.php>
37
39. Variable Wrap-up!
• A variable can be reassigned (the tag can be stuck
on a new thing) at any time by a program
– One of the most common “bugs” in programming is
changing the wrong variable or changing the right
variable at the wrong time
– One way to prevent this is to use variable names that
are easy to remember and have contextual meaning
• $t = 'Mr. Morton' or $x1796vc47blahblah = 'Mr. Morton'
work but have no meaning
39
40. Quiz
• Once you have created a variable, can you change
the value assigned to it?
• With variable names, is $TEACHER the same as
$TEACHEr?
• Is ‘Blah’ the same as “Blah”?
• Is ‘4’ the same as 4?
• Is “10” a number or a string?
• How do you tell PHP that a variable is string or a
number?
40
41. Basic Math
• The four basic operations:
– Addition: +
– Subtraction: -
– Multiplication: *
– Division: /
• Exponentiation [PHP: pow($base, $exponent)]
– Raising a number to a power: 25= 2*2*2*2*2
• Modulus [PHP: %]
– Clock arithmetic
• Increment and decrement
$Score = $Score + 1;
++$Score;
$Score += 1;
• Really big numbers, really small numbers
– Overflow, underflow, e-notation
41
42. Order of Operation
• PEMDAS
– Parentheses
– Exponents
– Multiply
– Divide
– Add
– Subtract
• But be kind and use parentheses!
– (2 + 3) * 4 = 20
– 2 + (3 * 4) = 14
42
43. Data Types
• So far, we have talked about three data types
– Strings
– Integers
– Reals/decimals (floats)
• Sometimes we have have to be careful about what
types we use
• Fancy words alert: Data type Conversion
– A programming language will have explicit ways to convert
from one data type to another, also called type casting!
– Integer to float: $newFloat = (float) $oldInteger;
– Float to integer: $newInteger = (int) $oldFloat;
– String to float/integer: $number = $stringasnumber;
43
44. Gotchas will getcha
• Be careful casting an unknown fraction (float)
to an integer
print (int)( (0.1+0.7) * 10 );
• Result is …
• 7 Why?
• There are many helper functions for casting:
– floor()
– ceil()
– round()
44
45. Quiz
• What symbol does PHP use for multiplication?
• How would you get the remainder for 8 / 3?
• How would you get the integer part for 8 / 3?
• What’s another way of calculating 6 * 6 * 6 * 6
in PHP?
45
48. Exercise 1
• Write a short PHP program, as we just did,
that will print three lines:
– Your name
– Your birth date
– Your favorite color
• My name is James Marcus.
• I was born January 26, 1961.
• My favorite color is blue.
48
49. Exercise 2
• Calculate the number of minutes in a week
using variables
– $DaysPerWeek
– $HoursPerDay
– $MinutesPerHour
• How many minutes are there in a week in the
Bilky Way, a near parallel galaxy, if there are
26 hours on a day there?
49
Editor's Notes
Separation of presentation and structure (CSS and HTML);Separation of behavior and structure (JavaScript and HTML);Separation of behavior and presentation (JavaScript and CSS)
Different languages run on the different components.Browser: HTML, CSS, JavascriptWeb Server: PHP, ASP, JSP, CFDatabase Server: SQL
What could be wrong? Not the write keyword, used the keyword incorrectly, logic problems, and lots of other reasons.
Somewhere in a chunk of your computer’s memory, the letters “Mr. Morton” exist. You don’t need to know exactly where. You said that the name for that series of letters is Teacher, and that’s how you will refer to it from now on. A name is like a label or tag or sticky note that you attach to something to identify what it is.When you put quotes around something, most computer languagestake it literally. It prints exactly what is in the quotes. When you don’t put quotes around the thing, the languagehas to figure out what the thing is. It could be a number (like 5), an expression (like 5 + 3), or a name (like Teacher).
In this example, instead of doing the sum in the print instruction, we took the thing named First and the thing named Second and added them together, creating a new thing, called Third. Third is the sum of First and Second.
But you do have to use the same kind of quotes at the start and the end of the string.
Whenever we make a variable equal something, the variable always appears on the left side of the equal sign (=). The trick is that the variable can also appear on the right. This turns out to be quite useful, and you’ll see it in a lot of programs. The most common use is to increment a variable (increase it by a certain amount), like we just did, or the opposite, to decrement a variable (decrease it by a certain amount).