An State is called Flag State when the ships is registered in that country, the ships carries this flag. The Port State is any State with an international port. For example a ship is registered in Hong Kong and is in the port of Singapore. In this example is Hong Kong the flag state and Singapore is the Port State.
Each member (=flag state) from the IMO who is the administration of a port state has to install Port State officers. Those officers will inspect the ship according the international legislation and not according the national legislation.
For example an inspector from the flag state Hong Kong will inspect a ship which is in Singapore according the legislation of Hong Kong. So the inspection is according the minimum regulations of the conventions which are ratified by Hong Kong plus additional regulation of Hong Kong. The port state officer in Singapore will look at all the conventions which are in force from the IMO and ILO. The port state officer will not take the additional flag state legislation in consideration. If for example Hong Kong didn’t ratified one of the conventions, the port state officer still will look at this particular convention, while the flag state inspector will not look at this convention.