  Linear codes with few weights have applications in consumer electronics,
communication, data storage system, secret sharing, authentication codes,
association schemes, and strongly regular graphs. This paper first generalizes
the method of constructing two-weight and three-weight linear codes of Ding et
al. \cite{DD2015} and Zhou et al. \cite{ZLFH2015} to general weakly regular
bent functions and determines the weight distributions of these linear codes.
It solves the open problem of Ding et al. \cite{DD2015}. Further, this paper
constructs new linear codes with two or three weights and presents the weight
distributions of these codes. They contains some optimal codes meeting certain
bound on linear codes.
