Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 526227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:45:14+00:00 2026-05-13T08:45:14+00:00

The way I understand it, the following is allowed in PHP because it’s a

  • 0

The way I understand it, the following is allowed in PHP because it’s a weakly-typed language.

$var = 'Hello';
$var = 5;

I just installed a Windows version of Python 2.6 and I was expecting it NOT to let me change type just like that, but the Python equivalent of the above code works just like in PHP yikes!

>>> var = "Hello"
>>> type(var)
<type 'str'>
>>> var = 5
>>> type(var)
<type 'int'>

Is my understanding of weak/strong typing flawed?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T08:45:14+00:00Added an answer on May 13, 2026 at 8:45 am

    Your example demonstrates dynamic typing, not weak typing. Dynamic typing generally means that the type of data an object can store is mutable; any target may hold a binding to any kind of object. Contrast that with, say, C#, which is statically typed [*].

    int i = 5; // Okay.
    i = "5";   // Illegal! i can only hold integers.
    

    Strong typing means that once assigned a value of a particular kind, objects obey strict rules about how they can interact with other objects of various types. Weak typing means that such rules are more relaxed. This doesn’t mean that strongly typed languages are necessarily superior in any way; it’s just a language design choice.

    Python is considered strongly typed because objects have a distinct notion of what they type they are. Incompatible operations between objects cause errors:

    >>> 1 + 1          # Add two integers.
    2
    >>> "1" + "1"      # Concatenate two strings.
    '11'
    >>> 1 + int("1")   # Add two integers.
    2
    >>> "1" + str(1)   # Concatenate two strings.
    '11'
    >>> 1 + "1"        # Undefined! Adding integers and strings is meaningless.
    Traceback (most recent call last):
      File "", line 5, in ?
    TypeError: unsupported operand type(s) for +: 'int' and 'str'
    

    But in PHP, the rules are much more relaxed about what is acceptable. Thus it is considered more weakly typed than some other languages.

    $x = 1 + "1"; // x is 2
    

    [*] Technically, as of C# 4, C# is statically typed but with opt-in dynamic typing on a per-binding basis, thanks to the dynamic keyword. A lot of languages these days are adding dynamic capabilities and blurring the lines, so it’s becoming increasingly harder to say that “language X is dynamic” and “language Y is static”. It’s much more of a sliding scale or a spectrum than it is a binary property.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anybody know if there is a way to understand what users are doing
How can polymorphism be described in an easy-to-understand way? We can find a lot
I understand the best way to count the number of rows in an SQL
I understand, in a fuzzy sort of way, how regular ACID transactions work. You
is there any way to make IE6 understand double classes, say I have a
Is there a way that I can configure Visual Studio 2008 to understand CamelCase?
I'm not completely sure I understand the workflow way of doing things, but if
Why was C# designed this way? As I understand it, an interface only describes
I think I understand unit testing. But I was wondering: is there a way
I could understand the following search algorithms: Constraint Satisfaction with Arc Consistency, Uninformed search

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.