Skip to content
Home Blog Web Design Complex Conditional Statements

Complex Conditional Statements

  • Web Design
Blueprint Digital
Blueprint Digital

Insights from the Blueprint Digital team.

“If I had won the lottery, I would have bought a boat.” In this sentence, it is impossible for the condition to be fulfilled, because it refers to an event in the past. I neither won the lottery, nor bought a boat.

Like the English language, programming languages make extensive use of conditional statements. When writing programming functions, conditional clauses are always given a boolean value of true or false. If the sentence in the lottery example was implemented into code in a conditional statement, it would return ‘false’, because neither condition can be fulfilled.

Web developers and other programers can combine multiple conditional clauses to make complex conditional statements. For example, suppose I have two php values called $p and $q, with values of “2=2” and “3=5”, respectively. $p is true and $q is false. I can compare these expressions with ‘and’ and ‘or’. $p AND $q returns ‘false’, because something cannot be both true and false simultaneously. The statement $p OR $q returns ‘true’, because at least one of the statements is true.

Conditionals become increasingly difficult when one or more ‘NOT’ clauses is present. A truth table can aid in deciphering the logic behind these complex conditional statements.

p q p AND q p OR q NOT (p OR q) NOT p NOT q (NOT p) OR (NOT q)
T T T T F F F F
T F F T T F T T
F T F T T T F T
F F F F T T T T

 

If you know the boolean value for both p and q, you can apply them to the table. For example, if you are looking to solve for either NOT p or NOT q, and p and q are both true, the conditional would return false, as indicated by the first line of the table. Truth tables are a handy way of quickly determining the outcome of your conditional statement.

Ready to Dominate Online and Grow Your Business?

Schedule time to connect with Blueprint about your online goals, or request a free review of marketing campaigns.

Related Posts

Digital Marketing for Orthopedic Surgeons

Digital Marketing for Orthopedic Surgeons

Orthopedic practices used to fill their schedules through physician referrals. Patients now find and choose their own surgeon online, often before a referral enters the picture. Someone with knee pain or a torn rotator cuff will research the problem and compare practices before calling any of them. Digital marketing for orthopedic surgeons reaches those patients[...]
How to Find AI Search Ranking Opportunities Your Competitors Are Winning (With Semrush)

How to Find AI Search Ranking Opportunities Your Competitors Are Winning (With Semrush)

If you’ve spent any time watching how people search over the past year, you’ve probably noticed a shift. More users are asking ChatGPT, Google’s AI Overviews, Perplexity, and other AI-powered search tools for recommendations instead of clicking through a page of blue links. While traditional SEO remains an important part of a digital marketing strategy,[...]
Personal Injury Marketing: A 2026 Playbook

Personal Injury Marketing: A 2026 Playbook

Injury care is one of the hardest categories in healthcare to market. Patients decide within days of getting hurt, and the keywords that reach them are among the most expensive in search. A practice can rank at the top of Google and still lose the patient to a competitor who answered the phone first. Personal[...]
Previous
Next

Partner with BLUEPRINT to reach your online goals, grow your business and reshape your story.

Get in touch with BLUEPRINT

Reach out to request a discovery call, a free campaign review, or for all other inquiries.

Subscribe to our newsletter